云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > activemq-cpp开发手册

activemq-cpp开发手册

  • 62 次阅读
  • 3 次下载
  • 2025/6/14 23:16:53

6 消息类型

CMS支持TextMessage, MapMessage, ByteMessage, ObjectMessage四种消息类型,其都继承自cms::Message类型。

以上几个消息类都是抽象类,不能直接实例化。在实际使用中通常以指针形式出现,指向由调用Session类的方法创建的具体实类。

指向具体消息类的指针在消息发送时向上转换成基类指针Message*, 接收又将基类指针强制向下转换成具体的消息类型指针。如

发送时:

TextMessage* txt=session.createTextMessage(); txt->setText(“hello world\\n”);

sender.send(txt); // send参数是Message* 做向上转换 接收时:

virtual void onMessage(const Message* msg){ // 强制向下转换

TextMessage* txt=dynamic_cast(msg); // do something }

6.1 cms::Message 6.1.1 概述

cms::Message是cms中所有消息的抽象基类,包含三部分:消息头,消息体,用户定义属性。 详情参考http://activemq.apache.org/cms/api_docs/activemqcpp-2.1/classcms_1_1_message.html

6.1.2 接口

6.1.2.1 virtual cms::Message::~Message ( ) [inline, virtual] 6.1.2.2 virtual Message* cms::Message::clone () const [pure

virtual]

Clone this message exactly, returns a new instance that the caller is required to delete. Returns:

new copy of this message

6.1.2.3 virtual void cms::Message::acknowledge () const throw

( CMSException ) [pure virtual]

Acknowledges all consumed messages of the session of this consumed message.

All consumed CMS messages support the acknowledge method for use when a client has specified that its CMS session's consumed messages are to be explicitly acknowledged. By invoking acknowledge on a consumed message, a client acknowledges all messages consumed by the session that the message was delivered to.

Calls to acknowledge are ignored for both transacted sessions and sessions specified to use implicit acknowledgement modes.

A client may individually acknowledge each message as it is consumed, or it may choose to acknowledge messages as an application-defined group (which is done by calling acknowledge on the last received message of the group, thereby acknowledging all messages consumed by the session.)

Messages that have been received but not acknowledged may be redelivered.

6.1.2.4 virtual void cms::Message::clearBody () [pure virtual]

Clears out the body of the message.

This does not clear the headers or properties.

6.1.2.5 virtual void cms::Message::clearProperties () [pure

virtual]

Clears out the message body.

Clearing a message's body does not clear its header values or property entries.

If this message body was read-only, calling this method leaves the message body in the same state as an empty body in a newly created message.

6.1.2.6 Virtual std::vector

cms::Message::getPropertyName () const [pure virtual]

Retrieves the propery names.

Returns:

The complete set of property names currently in this message.

6.1.2.7 virtual bool cms::Message::propertyExists ( const

std::string & name) const [pure virtual]

Indicates whether or not a given property exists.

Parameters: name The name of the property to look up.

Returns:

True if the property exists in this message.

6.1.2.8 virtual bool cms::Message::getBooleanProperty (const

std::string & name) const throw ( CMSException ) [pure virtual]

Gets a boolean property.

Parameters: name The name of the property to retrieve.

Returns:

The value for the named property.

Exceptions: CMSException if the property does not exist.

6.1.2.9 virtual unsigned char cms::Message::getByteProperty

( const std::string & name) const throw ( CMSException ) [pure virtual]

Gets a byte property.

Parameters: name The name of the property to retrieve.

Returns:

The value for the named property.

Exceptions: CMSException if the property does not exist.

6.1.2.10 virtual double cms::Message::getDoubleProperty

( const std::string & name) const throw ( CMSException ) [pure virtual]

Gets a double property.

Parameters: name The name of the property to retrieve.

Returns:

The value for the named property.

Exceptions: CMSException if the property does not exist.

搜索更多关于: activemq-cpp开发手册 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

6 消息类型 CMS支持TextMessage, MapMessage, ByteMessage, ObjectMessage四种消息类型,其都继承自cms::Message类型。 以上几个消息类都是抽象类,不能直接实例化。在实际使用中通常以指针形式出现,指向由调用Session类的方法创建的具体实类。 指向具体消息类的指针在消息发送时向上转换成基类指针Message*, 接收又将基类指针强制向下转换成具体的消息类型指针。如 发送时: TextMessage* txt=session.createTextMessage(); txt->setText(“hello world\\n”); sender.send(txt); // send参数是M

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com