activemq-cpp-3.9.5
ActiveMQSession.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#ifndef _ACTIVEMQ_CORE_ACTIVEMQSESSION_H_
18#define _ACTIVEMQ_CORE_ACTIVEMQSESSION_H_
19
20#include <cms/Session.h>
22
28
29#include <decaf/lang/Pointer.h>
30
31#include <string>
32#include <memory>
33
34namespace activemq {
35namespace core {
36
37 using decaf::lang::Pointer;
38 using decaf::util::concurrent::atomic::AtomicBoolean;
39
41
42 class AMQCPP_API ActiveMQSession : public virtual cms::Session {
43 protected:
44
46
47 private:
48
49 ActiveMQSession(const ActiveMQSession&);
50 ActiveMQSession& operator=(const ActiveMQSession&);
51
52 public:
53
55
57
61 virtual void start();
62
66 virtual void stop();
67
72 bool isStarted() const {
73 return this->kernel->isStarted();
74 }
75
76 public: // Implements Methods
77
78 virtual void close();
79
80 virtual void commit();
81
82 virtual void rollback();
83
84 virtual void recover();
85
87
89 const std::string& selector);
90
92 const std::string& selector,
93 bool noLocal);
94
96 const std::string& name,
97 const std::string& selector,
98 bool noLocal = false);
99
101
103
104 virtual cms::QueueBrowser* createBrowser(const cms::Queue* queue, const std::string& selector);
105
106 virtual cms::Queue* createQueue(const std::string& queueName);
107
108 virtual cms::Topic* createTopic(const std::string& topicName);
109
111
113
115
117
118 virtual cms::BytesMessage* createBytesMessage(const unsigned char* bytes, int bytesSize);
119
121
123
124 virtual cms::TextMessage* createTextMessage(const std::string& text);
125
127
129 return this->kernel->getAcknowledgeMode();
130 }
131
132 virtual bool isTransacted() const {
133 return this->kernel->isTransacted();
134 }
135
136 virtual void unsubscribe(const std::string& name);
137
138 public: // ActiveMQSession specific Methods
139
148 return this->kernel->getExceptionListener();
149 }
150
159 this->kernel->setMessageTransformer(transformer);
160 }
161
168 return this->kernel->getMessageTransformer();
169 }
170
177 return this->kernel->getSessionInfo();
178 }
179
186 return this->kernel->getSessionId();
187 }
188
193 return this->kernel->getConnection();
194 }
195
196 };
197
198}}
199
200#endif /*_ACTIVEMQ_CORE_ACTIVEMQSESSION_H_*/
#define AMQCPP_API
Definition Config.h:30
Definition SessionId.h:51
Definition SessionInfo.h:48
Concrete connection used for all connectors to the ActiveMQ broker.
Definition ActiveMQConnection.h:62
virtual cms::QueueBrowser * createBrowser(const cms::Queue *queue)
Creates a new QueueBrowser to peek at Messages on the given Queue.
Pointer< activemq::core::kernels::ActiveMQSessionKernel > kernel
Definition ActiveMQSession.h:45
virtual void stop()
Starts asynchronous message delivery.
virtual void start()
Stops asynchronous message delivery.
virtual void setMessageTransformer(cms::MessageTransformer *transformer)
Set an MessageTransformer instance that is passed on to all MessageProducer and MessageConsumer objec...
Definition ActiveMQSession.h:158
ActiveMQConnection * getConnection() const
Gets the ActiveMQConnection that is associated with this session.
Definition ActiveMQSession.h:192
virtual cms::StreamMessage * createStreamMessage()
Creates a new StreamMessage.
virtual cms::TextMessage * createTextMessage()
Creates a new TextMessage.
virtual cms::BytesMessage * createBytesMessage(const unsigned char *bytes, int bytesSize)
Creates a BytesMessage and sets the payload to the passed value.
virtual cms::Session::AcknowledgeMode getAcknowledgeMode() const
Returns the acknowledgment mode of the session.
Definition ActiveMQSession.h:128
virtual cms::MessageConsumer * createDurableConsumer(const cms::Topic *destination, const std::string &name, const std::string &selector, bool noLocal=false)
Creates a durable subscriber to the specified topic, using a Message selector.
virtual cms::MessageConsumer * createConsumer(const cms::Destination *destination)
Creates a MessageConsumer for the specified destination.
virtual cms::MessageTransformer * getMessageTransformer() const
Gets the currently configured MessageTransformer for this Session.
Definition ActiveMQSession.h:167
virtual cms::TextMessage * createTextMessage(const std::string &text)
Creates a new TextMessage and set the text to the value given.
ActiveMQSession(Pointer< activemq::core::kernels::ActiveMQSessionKernel > kernel)
const commands::SessionId & getSessionId() const
Gets the Session Id object for this session, if the session is closed than this method throws an exce...
Definition ActiveMQSession.h:185
virtual bool isTransacted() const
Gets if the Sessions is a Transacted Session.
Definition ActiveMQSession.h:132
virtual cms::QueueBrowser * createBrowser(const cms::Queue *queue, const std::string &selector)
Creates a new QueueBrowser to peek at Messages on the given Queue.
const commands::SessionInfo & getSessionInfo() const
Gets the Session Information object for this session, if the session is closed than this method throw...
Definition ActiveMQSession.h:176
virtual void rollback()
Rolls back all messages done in this transaction and releases any locks currently held.
virtual cms::MapMessage * createMapMessage()
Creates a new MapMessage.
virtual cms::TemporaryTopic * createTemporaryTopic()
Creates a TemporaryTopic object.
virtual void unsubscribe(const std::string &name)
Unsubscribes a durable subscription that has been created by a client.
virtual void close()
Closes this session as well as any active child consumers or producers.
virtual cms::MessageConsumer * createConsumer(const cms::Destination *destination, const std::string &selector)
Creates a MessageConsumer for the specified destination, using a message selector.
virtual cms::TemporaryQueue * createTemporaryQueue()
Creates a TemporaryQueue object.
virtual cms::Topic * createTopic(const std::string &topicName)
Creates a topic identity given a Queue name.
cms::ExceptionListener * getExceptionListener()
This method gets any registered exception listener of this sessions connection and returns it.
Definition ActiveMQSession.h:147
virtual void recover()
Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged ...
virtual void commit()
Commits all messages done in this transaction and releases any locks currently held.
virtual cms::Message * createMessage()
Creates a new Message.
virtual cms::MessageProducer * createProducer(const cms::Destination *destination)
Creates a MessageProducer to send messages to the specified destination.
virtual cms::MessageConsumer * createConsumer(const cms::Destination *destination, const std::string &selector, bool noLocal)
Creates a MessageConsumer for the specified destination, using a message selector.
virtual cms::BytesMessage * createBytesMessage()
Creates a BytesMessage.
bool isStarted() const
Indicates whether or not the session is currently in the started state.
Definition ActiveMQSession.h:72
virtual cms::Queue * createQueue(const std::string &queueName)
Creates a queue identity given a Queue name.
A BytesMessage object is used to send a message containing a stream of unsigned bytes.
Definition BytesMessage.h:66
A Destination object encapsulates a provider-specific address.
Definition Destination.h:39
If a CMS provider detects a serious problem, it notifies the client application through an ExceptionL...
Definition ExceptionListener.h:37
A MapMessage object is used to send a set of name-value pairs.
Definition MapMessage.h:71
A client uses a MessageConsumer to received messages from a destination.
Definition MessageConsumer.h:63
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
This class implements in interface for browsing the messages in a Queue without removing them.
Definition QueueBrowser.h:53
An interface encapsulating a provider-specific queue name.
Definition Queue.h:37
A Session object is a single-threaded context for producing and consuming messages.
Definition Session.h:105
AcknowledgeMode
Definition Session.h:108
Interface for a StreamMessage.
Definition StreamMessage.h:61
Defines a Temporary Queue based Destination.
Definition TemporaryQueue.h:39
Defines a Temporary Topic based Destination.
Definition TemporaryTopic.h:39
Interface for a text message.
Definition TextMessage.h:41
An interface encapsulating a provider-specific topic name.
Definition Topic.h:36
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 ActiveMQTempDestination.h:29
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24