summaryrefslogtreecommitdiff
path: root/doc/book/src/Cheat-Sheet-for-configuring-Exchange-Options.xml
blob: fccdae1b9a19954cf17e35cf7e83459c268295eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?xml version="1.0" encoding="utf-8"?>

<!--
 
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at
 
   http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 
-->

<section>
  <title>
    Cheat Sheet for configuring Exchange Options
  </title>

  <section role="h2" id="CheatSheetforconfiguringExchangeOptions-ConfiguringExchangeOptions">
    <title>
      Configuring Exchange Options
    </title>
          <para>
            The C++ Broker M4 or later supports the following additional
            Exchange options in addition to the standard AMQP define options
          </para><itemizedlist>
            <listitem><para>Exchange Level Message sequencing
            </para></listitem>
            <listitem><para>Initial Value Exchange
            </para></listitem>
          </itemizedlist><para>
            Note that these features can be used on any exchange type, that
            has been declared with the options set.
          </para><para>
            It also supports an additional option to the bind operation on a
            direct exchange
          </para><itemizedlist>
            <listitem><para>Exclusive binding for key
            </para></listitem>
          </itemizedlist>

	  <section role="h3" id="CheatSheetforconfiguringExchangeOptions-ExchangeLevelMessagesequencing"><title>
            Exchange Level Message sequencing
          </title>
          <para>
            This feature can be used to place a sequence number into each
            message's headers, based on the order they pass through an
            exchange. The sequencing starts at 0 and then wraps in an AMQP
            int64 type.
          </para><para>
            The field name used is "qpid.msg_sequence"
          </para><para>
            To use this feature an exchange needs to be declared specifying
            this option in the declare
          </para>
            <programlisting>
....
    FieldTable args;
    args.setInt("qpid.msg_sequence",1);

...
    // now declare the exchange
    session.exchangeDeclare(arg::exchange="direct", arg::arguments=args);
</programlisting>
          <para>
            Then each message passing through that exchange will be numbers
            in the application headers.
          </para>
            <programlisting>
    unit64_t seqNo;
    //after message transfer
    seqNo = message.getHeaders().getAsInt64("qpid.msg_sequence");
</programlisting>
	  <!--h3--></section>
          <section role="h3" id="CheatSheetforconfiguringExchangeOptions-InitialValueExchange"><title>
            Initial
            Value Exchange
          </title>
          <para>
            This feature caches a last message sent to an exchange. When a
            new binding is created onto the exchange it will then attempt to
            route this cached messaged to the queue, based on the binding.
            This allows for topics or the creation of configurations where a
            new consumer can receive the last message sent to the broker,
            with matching routing.
          </para><para>
            To use this feature an exchange needs to be declared specifying
            this option in the declare
          </para>
            <programlisting>
....
    FieldTable args;
    args.setInt("qpid.ive",1);

...
    // now declare the exchange
    session.exchangeDeclare(arg::exchange="direct", arg::arguments=args);
</programlisting>
          <para>
            now use the exchange in the same way you would use any other
            exchange.
          </para>
	  <!--h3--></section>

	  <section role="h3" id="CheatSheetforconfiguringExchangeOptions-Exclusivebindingforkey"><title>
            Exclusive
            binding for key
          </title>
          <para>
            Direct exchanges in qpidd support a qpid.exclusive-binding option
            on the bind operation that causes the binding specified to be the
            only one for the given key. I.e. if there is already a binding at
            this exchange with this key it will be atomically updated to bind
            the new queue. This means that the binding can be changed
            concurrently with an incoming stream of messages and each message
            will be routed to exactly one queue.
          </para>
            <programlisting>
....
    FieldTable args;
    args.setInt("qpid.exclusive-binding",1);

    //the following will cause the only binding from amq.direct with 'my-key' 
    //to be the one to 'my-queue'; if there were any previous bindings for that
    //key they will be removed. This is atomic w.r.t message routing through the
    //exchange.
    session.exchangeBind(arg::exchange="amq.direct", arg::queue="my-queue",
                         arg::bindingKey="my-key", arg::arguments=args);

...
</programlisting>
<!--h3--></section>
<!--h2--></section>
</section>