activemq-cpp-3.9.5
Session.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 _CMS_SESSION_H_
18#define _CMS_SESSION_H_
19
20#include <cms/Config.h>
21#include <cms/Closeable.h>
22#include <cms/Startable.h>
23#include <cms/Stoppable.h>
24#include <cms/Message.h>
25#include <cms/TextMessage.h>
26#include <cms/BytesMessage.h>
27#include <cms/MapMessage.h>
28#include <cms/StreamMessage.h>
29#include <cms/MessageProducer.h>
30#include <cms/MessageConsumer.h>
31#include <cms/Topic.h>
32#include <cms/Queue.h>
33#include <cms/QueueBrowser.h>
34#include <cms/TemporaryTopic.h>
35#include <cms/TemporaryQueue.h>
36#include <cms/CMSException.h>
37
38namespace cms {
39
41
105 class CMS_API Session : public Closeable, public Startable, public Stoppable {
106 public:
107
149
150 public:
151
152 virtual ~Session();
153
160 virtual void close() = 0;
161
169 virtual void commit() = 0;
170
178 virtual void rollback() = 0;
179
200 virtual void recover() = 0;
201
213 virtual MessageConsumer* createConsumer(const Destination* destination) = 0;
214
230 virtual MessageConsumer* createConsumer(const Destination* destination, const std::string& selector) = 0;
231
251 virtual MessageConsumer* createConsumer(const Destination* destination, const std::string& selector, bool noLocal) = 0;
252
276 virtual MessageConsumer* createDurableConsumer(const Topic* destination, const std::string& name, const std::string& selector, bool noLocal = false) = 0;
277
289 virtual MessageProducer* createProducer(const Destination* destination = NULL) = 0;
290
301 virtual QueueBrowser* createBrowser(const cms::Queue* queue) = 0;
302
315 virtual QueueBrowser* createBrowser(const cms::Queue* queue, const std::string& selector) = 0;
316
326 virtual Queue* createQueue(const std::string& queueName) = 0;
327
337 virtual Topic* createTopic(const std::string& topicName) = 0;
338
347
354
360 virtual Message* createMessage() = 0;
361
368
379 virtual BytesMessage* createBytesMessage(const unsigned char* bytes, int bytesSize) = 0;
380
387
394
403 virtual TextMessage* createTextMessage(const std::string& text) = 0;
404
411
420
428 virtual bool isTransacted() const = 0;
429
446 virtual void unsubscribe(const std::string& name) = 0;
447
459 virtual void setMessageTransformer(cms::MessageTransformer* transformer) = 0;
460
467
468 };
469
470}
471
472#endif /*_CMS_SESSION_H_*/
A BytesMessage object is used to send a message containing a stream of unsigned bytes.
Definition BytesMessage.h:66
Interface for a class that implements the close method.
Definition Closeable.h:35
A Destination object encapsulates a provider-specific address.
Definition Destination.h:39
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
virtual void setMessageTransformer(cms::MessageTransformer *transformer)=0
Set an MessageTransformer instance that is passed on to all MessageProducer and MessageConsumer objec...
virtual cms::MessageTransformer * getMessageTransformer() const =0
Gets the currently configured MessageTransformer for this Session.
virtual void rollback()=0
Rolls back all messages done in this transaction and releases any locks currently held.
virtual MessageConsumer * createConsumer(const Destination *destination, const std::string &selector)=0
Creates a MessageConsumer for the specified destination, using a message selector.
virtual AcknowledgeMode getAcknowledgeMode() const =0
Returns the acknowledgment mode of the session.
virtual Queue * createQueue(const std::string &queueName)=0
Creates a queue identity given a Queue name.
virtual bool isTransacted() const =0
Gets if the Sessions is a Transacted Session.
virtual TextMessage * createTextMessage()=0
Creates a new TextMessage.
virtual MessageConsumer * createDurableConsumer(const Topic *destination, const std::string &name, const std::string &selector, bool noLocal=false)=0
Creates a durable subscriber to the specified topic, using a Message selector.
virtual void commit()=0
Commits all messages done in this transaction and releases any locks currently held.
virtual Message * createMessage()=0
Creates a new Message.
virtual void recover()=0
Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged ...
virtual TemporaryTopic * createTemporaryTopic()=0
Creates a TemporaryTopic object.
virtual void unsubscribe(const std::string &name)=0
Unsubscribes a durable subscription that has been created by a client.
virtual Topic * createTopic(const std::string &topicName)=0
Creates a topic identity given a Queue name.
virtual MapMessage * createMapMessage()=0
Creates a new MapMessage.
virtual StreamMessage * createStreamMessage()=0
Creates a new StreamMessage.
virtual TextMessage * createTextMessage(const std::string &text)=0
Creates a new TextMessage and set the text to the value given.
virtual MessageConsumer * createConsumer(const Destination *destination, const std::string &selector, bool noLocal)=0
Creates a MessageConsumer for the specified destination, using a message selector.
virtual void close()=0
Closes this session as well as any active child consumers or producers.
virtual BytesMessage * createBytesMessage()=0
Creates a BytesMessage.
virtual TemporaryQueue * createTemporaryQueue()=0
Creates a TemporaryQueue object.
virtual QueueBrowser * createBrowser(const cms::Queue *queue)=0
Creates a new QueueBrowser to peek at Messages on the given Queue.
virtual MessageProducer * createProducer(const Destination *destination=NULL)=0
Creates a MessageProducer to send messages to the specified destination.
virtual ~Session()
AcknowledgeMode
Definition Session.h:108
@ SESSION_TRANSACTED
Messages will be consumed when the transaction commits.
Definition Session.h:139
@ INDIVIDUAL_ACKNOWLEDGE
Message will be acknowledged individually.
Definition Session.h:146
@ AUTO_ACKNOWLEDGE
With this acknowledgment mode, the session automatically acknowledges a client's receipt of a message...
Definition Session.h:117
@ DUPS_OK_ACKNOWLEDGE
With this acknowledgment mode, the session automatically acknowledges a client's receipt of a message...
Definition Session.h:128
@ CLIENT_ACKNOWLEDGE
With this acknowledgment mode, the client acknowledges a consumed message by calling the message's ac...
Definition Session.h:134
virtual BytesMessage * createBytesMessage(const unsigned char *bytes, int bytesSize)=0
Creates a BytesMessage and sets the payload to the passed value.
virtual QueueBrowser * createBrowser(const cms::Queue *queue, const std::string &selector)=0
Creates a new QueueBrowser to peek at Messages on the given Queue.
virtual MessageConsumer * createConsumer(const Destination *destination)=0
Creates a MessageConsumer for the specified destination.
Interface for a class that implements the start method.
Definition Startable.h:36
Interface for a class that implements the stop method.
Definition Stoppable.h:36
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
#define CMS_API
Definition Config.h:31
#define NULL
Definition Config.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition DestinationResolver.h:23