activemq-cpp-3.9.5
ActiveMQProducerKernel.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _ACTIVEMQ_CORE_KERNELS_ACTIVEMQPRODUCERKERNEL_H_
19#define _ACTIVEMQ_CORE_KERNELS_ACTIVEMQPRODUCERKERNEL_H_
20
21#include <cms/MessageProducer.h>
22#include <cms/Message.h>
23#include <cms/Destination.h>
24#include <cms/DeliveryMode.h>
26
33
34#include <memory>
35
36namespace activemq {
37namespace core {
38namespace kernels {
39
40 using decaf::lang::Pointer;
41
43
44 class AMQCPP_API ActiveMQProducerKernel : public cms::MessageProducer {
45 private:
46
47 // Disable sending timestamps
48 bool disableTimestamps;
49
50 // Disable adding a Message Id
51 bool disableMessageId;
52
53 // The default delivery Mode of this Producer
54 int defaultDeliveryMode;
55
56 // The default priority Level to send at
57 int defaultPriority;
58
59 // The default time to live value for messages in milliseconds
60 long long defaultTimeToLive;
61
62 // The default Send Timeout for this Producer.
63 long long sendTimeout;
64
65 // Session that this producer sends to.
66 ActiveMQSessionKernel* session;
67
68 // This Producers protocol specific info object
70
71 // Boolean that indicates if the consumer has been closed
72 bool closed;
73
74 // Memory Usage Class, created only if the Producer is tracking its usage.
75 std::auto_ptr<util::MemoryUsage> memoryUsage;
76
77 // The Destination assigned at creation, NULL if not assigned.
78 Pointer<cms::Destination> destination;
79
80 // Generator of Message Sequence Id numbers for this producer.
81 util::LongSequenceGenerator messageSequence;
82
83 // Used to tranform Message before sending them to the CMS bus.
84 cms::MessageTransformer* transformer;
85
86 private:
87
88 ActiveMQProducerKernel(const ActiveMQProducerKernel&);
89 ActiveMQProducerKernel& operator=(const ActiveMQProducerKernel&);
90
91 public:
92
109 const Pointer<commands::ProducerId>& producerId,
111 long long sendTimeout);
112
114
115 public: // cms::MessageProducer methods.
116
117 virtual void close();
118
119 virtual void send(cms::Message* message);
120
121 virtual void send(cms::Message* message, cms::AsyncCallback* callback);
122
123 virtual void send(cms::Message* message, int deliveryMode, int priority, long long timeToLive);
124
125 virtual void send(cms::Message* message, int deliveryMode, int priority, long long timeToLive, cms::AsyncCallback* callback);
126
127 virtual void send(const cms::Destination* destination, cms::Message* message);
128
129 virtual void send(const cms::Destination* destination, cms::Message* message, cms::AsyncCallback* callback);
130
131 virtual void send(const cms::Destination* destination, cms::Message* message,
132 int deliveryMode, int priority, long long timeToLive);
133
134 virtual void send(const cms::Destination* destination, cms::Message* message,
135 int deliveryMode, int priority, long long timeToLive, cms::AsyncCallback* callback);
136
145 this->transformer = transformer;
146 }
147
154 return this->transformer;
155 }
156
161 virtual void setDeliveryMode(int mode) {
162 this->defaultDeliveryMode = mode;
163 }
164
169 virtual int getDeliveryMode() const {
170 return this->defaultDeliveryMode;
171 }
172
177 virtual void setDisableMessageID(bool value) {
178 this->disableMessageId = value;
179 }
180
185 virtual bool getDisableMessageID() const {
186 return this->disableMessageId;
187 }
188
193 virtual void setDisableMessageTimeStamp(bool value) {
194 this->disableTimestamps = value;
195 }
196
201 virtual bool getDisableMessageTimeStamp() const {
202 return this->disableTimestamps;
203 }
204
209 virtual void setPriority(int priority) {
210 this->defaultPriority = priority;
211 }
212
217 virtual int getPriority() const {
218 return this->defaultPriority;
219 }
220
225 virtual void setTimeToLive(long long time) {
226 this->defaultTimeToLive = time;
227 }
228
233 virtual long long getTimeToLive() const {
234 return this->defaultTimeToLive;
235 }
236
241 virtual void setSendTimeout(long long time) {
242 this->sendTimeout = time;
243 }
244
249 virtual long long getSendTimeout() const {
250 return this->sendTimeout;
251 }
252
256 bool isClosed() const {
257 return this->closed;
258 }
259
265 this->checkClosed();
266 return this->producerInfo;
267 }
268
274 this->checkClosed();
275 return this->producerInfo->getProducerId();
276 }
277
282 virtual void onProducerAck(const commands::ProducerAck& ack);
283
290 void dispose();
291
296 return this->messageSequence.getNextSequenceId();
297 }
298
299 private:
300
301 // Checks for the closed state and throws if so.
302 void checkClosed() const;
303
304 };
305
306}}}
307
308#endif /* _ACTIVEMQ_CORE_KERNELS_ACTIVEMQPRODUCERKERNEL_H_ */
#define AMQCPP_API
Definition Config.h:30
Definition ProducerAck.h:47
virtual void send(cms::Message *message, cms::AsyncCallback *callback)
Sends the message to the default producer destination, but does not take ownership of the message,...
virtual void close()
Closes this object and deallocates the appropriate resources.
const Pointer< commands::ProducerInfo > & getProducerInfo() const
Retries this object ProducerInfo pointer.
Definition ActiveMQProducerKernel.h:264
long long getNextMessageSequence()
Definition ActiveMQProducerKernel.h:295
bool isClosed() const
Definition ActiveMQProducerKernel.h:256
virtual bool getDisableMessageTimeStamp() const
Gets if Message Time Stamps are disabled for this Producer.
Definition ActiveMQProducerKernel.h:201
virtual void send(const cms::Destination *destination, cms::Message *message, int deliveryMode, int priority, long long timeToLive)
Sends the message to the designated destination, but does not take ownership of the message,...
virtual void setSendTimeout(long long time)
Sets the Send Timeout that this Producers sends messages with.
Definition ActiveMQProducerKernel.h:241
virtual void setTimeToLive(long long time)
Sets the Time to Live that this Producers sends messages with.
Definition ActiveMQProducerKernel.h:225
virtual bool getDisableMessageID() const
Gets if Message Ids are disabled for this Producer.
Definition ActiveMQProducerKernel.h:185
virtual long long getSendTimeout() const
Gets the Send Timeout that this producer sends messages with.
Definition ActiveMQProducerKernel.h:249
virtual cms::MessageTransformer * getMessageTransformer() const
Gets the currently configured MessageTransformer for this MessageProducer.
Definition ActiveMQProducerKernel.h:153
virtual void send(cms::Message *message, int deliveryMode, int priority, long long timeToLive)
Sends the message to the default producer destination, but does not take ownership of the message,...
virtual void setMessageTransformer(cms::MessageTransformer *transformer)
Set an MessageTransformer instance that is applied to all cms::Message objects before they are sent o...
Definition ActiveMQProducerKernel.h:144
virtual void setDisableMessageTimeStamp(bool value)
Sets if Message Time Stamps are disabled for this Producer.
Definition ActiveMQProducerKernel.h:193
virtual void onProducerAck(const commands::ProducerAck &ack)
Handles the work of Processing a ProducerAck Command from the Broker.
virtual void send(cms::Message *message, int deliveryMode, int priority, long long timeToLive, cms::AsyncCallback *callback)
Sends the message to the default producer destination, but does not take ownership of the message,...
virtual void setDisableMessageID(bool value)
Sets if Message Ids are disabled for this Producer.
Definition ActiveMQProducerKernel.h:177
void dispose()
Performs Producer object cleanup but doesn't attempt to send the Remove command to the broker.
virtual int getPriority() const
Gets the Priority level that this producer sends messages at.
Definition ActiveMQProducerKernel.h:217
virtual void setDeliveryMode(int mode)
Sets the delivery mode for this Producer.
Definition ActiveMQProducerKernel.h:161
virtual void send(const cms::Destination *destination, cms::Message *message, cms::AsyncCallback *callback)
Sends the message to the designated destination, but does not take ownership of the message,...
virtual long long getTimeToLive() const
Gets the Time to Live that this producer sends messages with.
Definition ActiveMQProducerKernel.h:233
virtual void send(const cms::Destination *destination, cms::Message *message)
Sends the message to the designated destination, but does not take ownership of the message,...
const Pointer< commands::ProducerId > & getProducerId() const
Retries this object ProducerId or NULL if closed.
Definition ActiveMQProducerKernel.h:273
virtual int getDeliveryMode() const
Gets the delivery mode for this Producer.
Definition ActiveMQProducerKernel.h:169
virtual void setPriority(int priority)
Sets the Priority that this Producers sends messages at.
Definition ActiveMQProducerKernel.h:209
virtual void send(cms::Message *message)
Sends the message to the default producer destination, but does not take ownership of the message,...
ActiveMQProducerKernel(ActiveMQSessionKernel *session, const Pointer< commands::ProducerId > &producerId, const Pointer< commands::ActiveMQDestination > &destination, long long sendTimeout)
Constructor, creates an instance of an ActiveMQProducerKernel.
virtual void send(const cms::Destination *destination, cms::Message *message, int deliveryMode, int priority, long long timeToLive, cms::AsyncCallback *callback)
Sends the message to the designated destination, but does not take ownership of the message,...
Definition ActiveMQSessionKernel.h:67
This class is used to generate a sequence of long long values that are incremented each time a new va...
Definition LongSequenceGenerator.h:32
Asynchronous event interface for CMS asynchronous operations.
Definition AsyncCallback.h:37
A Destination object encapsulates a provider-specific address.
Definition Destination.h:39
Root of all messages.
Definition Message.h:88
A client uses a MessageProducer object to send messages to a Destination.
Definition MessageProducer.h:60
Provides an interface for clients to transform cms::Message objects inside the CMS MessageProducer an...
Definition MessageTransformer.h:37
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition Pointer.h:53
Definition ActiveMQQueueBrowser.h:37
Definition ActiveMQTempDestination.h:29
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24