mirror of
https://github.com/apache/activemq.git
synced 2025-02-19 00:21:25 +00:00
Fixing eol-style
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/branches/activemq-4.0@426583 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a23f329fb7
commit
d44765df12
@ -1,270 +1,270 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
||||||
* applicable.
|
* applicable.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "activemq/command/AbstractCommand.hpp"
|
#include "activemq/command/AbstractCommand.hpp"
|
||||||
#include "activemq/command/ActiveMQMessage.hpp"
|
#include "activemq/command/ActiveMQMessage.hpp"
|
||||||
#include "activemq/command/ActiveMQBytesMessage.hpp"
|
#include "activemq/command/ActiveMQBytesMessage.hpp"
|
||||||
#include "activemq/command/ActiveMQMapMessage.hpp"
|
#include "activemq/command/ActiveMQMapMessage.hpp"
|
||||||
#include "activemq/command/ActiveMQObjectMessage.hpp"
|
#include "activemq/command/ActiveMQObjectMessage.hpp"
|
||||||
#include "activemq/command/ActiveMQStreamMessage.hpp"
|
#include "activemq/command/ActiveMQStreamMessage.hpp"
|
||||||
#include "activemq/command/ActiveMQTextMessage.hpp"
|
#include "activemq/command/ActiveMQTextMessage.hpp"
|
||||||
#include "activemq/command/ActiveMQQueue.hpp"
|
#include "activemq/command/ActiveMQQueue.hpp"
|
||||||
#include "activemq/command/ConsumerId.hpp"
|
#include "activemq/command/ConsumerId.hpp"
|
||||||
#include "activemq/command/ProducerId.hpp"
|
#include "activemq/command/ProducerId.hpp"
|
||||||
#include "activemq/command/MessageId.hpp"
|
#include "activemq/command/MessageId.hpp"
|
||||||
#include "activemq/command/LocalTransactionId.hpp"
|
#include "activemq/command/LocalTransactionId.hpp"
|
||||||
#include "activemq/command/MessageAck.hpp"
|
#include "activemq/command/MessageAck.hpp"
|
||||||
#include "activemq/command/MessageDispatch.hpp"
|
#include "activemq/command/MessageDispatch.hpp"
|
||||||
#include "activemq/command/Response.hpp"
|
#include "activemq/command/Response.hpp"
|
||||||
#include "activemq/command/ConsumerInfo.hpp"
|
#include "activemq/command/ConsumerInfo.hpp"
|
||||||
#include "activemq/command/IntegerResponse.hpp"
|
#include "activemq/command/IntegerResponse.hpp"
|
||||||
#include "activemq/command/ProducerInfo.hpp"
|
#include "activemq/command/ProducerInfo.hpp"
|
||||||
#include "activemq/command/BrokerInfo.hpp"
|
#include "activemq/command/BrokerInfo.hpp"
|
||||||
#include "activemq/command/KeepAliveInfo.hpp"
|
#include "activemq/command/KeepAliveInfo.hpp"
|
||||||
#include "activemq/command/ConnectionInfo.hpp"
|
#include "activemq/command/ConnectionInfo.hpp"
|
||||||
#include "activemq/command/RemoveInfo.hpp"
|
#include "activemq/command/RemoveInfo.hpp"
|
||||||
#include "activemq/command/RemoveSubscriptionInfo.hpp"
|
#include "activemq/command/RemoveSubscriptionInfo.hpp"
|
||||||
#include "activemq/command/SessionInfo.hpp"
|
#include "activemq/command/SessionInfo.hpp"
|
||||||
#include "activemq/command/TransactionInfo.hpp"
|
#include "activemq/command/TransactionInfo.hpp"
|
||||||
#include "activemq/command/WireFormatInfo.hpp"
|
#include "activemq/command/WireFormatInfo.hpp"
|
||||||
#include "activemq/command/BrokerId.hpp"
|
#include "activemq/command/BrokerId.hpp"
|
||||||
#include "activemq/command/ShutdownInfo.hpp"
|
#include "activemq/command/ShutdownInfo.hpp"
|
||||||
|
|
||||||
using namespace apache::activemq::command;
|
using namespace apache::activemq::command;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int AbstractCommand::getCommandId()
|
int AbstractCommand::getCommandId()
|
||||||
{
|
{
|
||||||
return commandId ;
|
return commandId ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void AbstractCommand::setCommandId(int id)
|
void AbstractCommand::setCommandId(int id)
|
||||||
{
|
{
|
||||||
commandId = id ;
|
commandId = id ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool AbstractCommand::getResponseRequired()
|
bool AbstractCommand::getResponseRequired()
|
||||||
{
|
{
|
||||||
return responseRequired ;
|
return responseRequired ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void AbstractCommand::setResponseRequired(bool value)
|
void AbstractCommand::setResponseRequired(bool value)
|
||||||
{
|
{
|
||||||
responseRequired = value ;
|
responseRequired = value ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
unsigned char AbstractCommand::getDataStructureType()
|
unsigned char AbstractCommand::getDataStructureType()
|
||||||
{
|
{
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool AbstractCommand::isMarshallAware()
|
bool AbstractCommand::isMarshallAware()
|
||||||
{
|
{
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int AbstractCommand::marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw(IOException)
|
int AbstractCommand::marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> writer) throw(IOException)
|
||||||
{
|
{
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void AbstractCommand::unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw(IOException)
|
void AbstractCommand::unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> reader) throw(IOException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
p<IDataStructure> AbstractCommand::createObject(unsigned char type)
|
p<IDataStructure> AbstractCommand::createObject(unsigned char type)
|
||||||
{
|
{
|
||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case ActiveMQMessage::TYPE:
|
case ActiveMQMessage::TYPE:
|
||||||
return new ActiveMQMessage() ;
|
return new ActiveMQMessage() ;
|
||||||
case ActiveMQTextMessage::TYPE:
|
case ActiveMQTextMessage::TYPE:
|
||||||
return new ActiveMQTextMessage() ;
|
return new ActiveMQTextMessage() ;
|
||||||
case ActiveMQObjectMessage::TYPE:
|
case ActiveMQObjectMessage::TYPE:
|
||||||
return new ActiveMQObjectMessage() ;
|
return new ActiveMQObjectMessage() ;
|
||||||
case ActiveMQBytesMessage::TYPE:
|
case ActiveMQBytesMessage::TYPE:
|
||||||
return new ActiveMQBytesMessage() ;
|
return new ActiveMQBytesMessage() ;
|
||||||
case ActiveMQStreamMessage::TYPE:
|
case ActiveMQStreamMessage::TYPE:
|
||||||
return new ActiveMQStreamMessage() ;
|
return new ActiveMQStreamMessage() ;
|
||||||
case ActiveMQMapMessage::TYPE:
|
case ActiveMQMapMessage::TYPE:
|
||||||
return new ActiveMQMapMessage() ;
|
return new ActiveMQMapMessage() ;
|
||||||
case ActiveMQQueue::TYPE:
|
case ActiveMQQueue::TYPE:
|
||||||
return new ActiveMQQueue() ;
|
return new ActiveMQQueue() ;
|
||||||
case ConsumerId::TYPE:
|
case ConsumerId::TYPE:
|
||||||
return new ConsumerId() ;
|
return new ConsumerId() ;
|
||||||
case ProducerId::TYPE:
|
case ProducerId::TYPE:
|
||||||
return new ProducerId() ;
|
return new ProducerId() ;
|
||||||
case MessageId::TYPE:
|
case MessageId::TYPE:
|
||||||
return new MessageId() ;
|
return new MessageId() ;
|
||||||
case LocalTransactionId::TYPE:
|
case LocalTransactionId::TYPE:
|
||||||
return new LocalTransactionId() ;
|
return new LocalTransactionId() ;
|
||||||
case MessageAck::TYPE:
|
case MessageAck::TYPE:
|
||||||
return new MessageAck() ;
|
return new MessageAck() ;
|
||||||
case MessageDispatch::TYPE:
|
case MessageDispatch::TYPE:
|
||||||
return new MessageDispatch() ;
|
return new MessageDispatch() ;
|
||||||
case Response::TYPE:
|
case Response::TYPE:
|
||||||
return new Response() ;
|
return new Response() ;
|
||||||
case ConsumerInfo::TYPE:
|
case ConsumerInfo::TYPE:
|
||||||
return new ConsumerInfo() ;
|
return new ConsumerInfo() ;
|
||||||
case ProducerInfo::TYPE:
|
case ProducerInfo::TYPE:
|
||||||
return new ProducerInfo() ;
|
return new ProducerInfo() ;
|
||||||
case TransactionInfo::TYPE:
|
case TransactionInfo::TYPE:
|
||||||
return new TransactionInfo() ;
|
return new TransactionInfo() ;
|
||||||
case BrokerInfo::TYPE:
|
case BrokerInfo::TYPE:
|
||||||
return new BrokerInfo() ;
|
return new BrokerInfo() ;
|
||||||
case BrokerId::TYPE:
|
case BrokerId::TYPE:
|
||||||
return new BrokerId() ;
|
return new BrokerId() ;
|
||||||
case ConnectionInfo::TYPE:
|
case ConnectionInfo::TYPE:
|
||||||
return new ConnectionInfo() ;
|
return new ConnectionInfo() ;
|
||||||
case SessionInfo::TYPE:
|
case SessionInfo::TYPE:
|
||||||
return new SessionInfo() ;
|
return new SessionInfo() ;
|
||||||
case RemoveSubscriptionInfo::TYPE:
|
case RemoveSubscriptionInfo::TYPE:
|
||||||
return new RemoveSubscriptionInfo() ;
|
return new RemoveSubscriptionInfo() ;
|
||||||
case IntegerResponse::TYPE:
|
case IntegerResponse::TYPE:
|
||||||
return new IntegerResponse() ;
|
return new IntegerResponse() ;
|
||||||
case WireFormatInfo::TYPE:
|
case WireFormatInfo::TYPE:
|
||||||
return new WireFormatInfo() ;
|
return new WireFormatInfo() ;
|
||||||
case RemoveInfo::TYPE:
|
case RemoveInfo::TYPE:
|
||||||
return new RemoveInfo() ;
|
return new RemoveInfo() ;
|
||||||
case KeepAliveInfo::TYPE:
|
case KeepAliveInfo::TYPE:
|
||||||
return new KeepAliveInfo() ;
|
return new KeepAliveInfo() ;
|
||||||
case ShutdownInfo::TYPE:
|
case ShutdownInfo::TYPE:
|
||||||
return new ShutdownInfo() ;
|
return new ShutdownInfo() ;
|
||||||
default:
|
default:
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
p<string> AbstractCommand::getDataStructureTypeAsString(unsigned char type)
|
p<string> AbstractCommand::getDataStructureTypeAsString(unsigned char type)
|
||||||
{
|
{
|
||||||
p<string> packetType = new string() ;
|
p<string> packetType = new string() ;
|
||||||
|
|
||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case ActiveMQMessage::TYPE:
|
case ActiveMQMessage::TYPE:
|
||||||
packetType->assign("ACTIVEMQ_MESSAGE") ;
|
packetType->assign("ACTIVEMQ_MESSAGE") ;
|
||||||
break ;
|
break ;
|
||||||
case ActiveMQTextMessage::TYPE:
|
case ActiveMQTextMessage::TYPE:
|
||||||
packetType->assign("ACTIVEMQ_TEXT_MESSAGE") ;
|
packetType->assign("ACTIVEMQ_TEXT_MESSAGE") ;
|
||||||
break ;
|
break ;
|
||||||
case ActiveMQObjectMessage::TYPE:
|
case ActiveMQObjectMessage::TYPE:
|
||||||
packetType->assign("ACTIVEMQ_OBJECT_MESSAGE") ;
|
packetType->assign("ACTIVEMQ_OBJECT_MESSAGE") ;
|
||||||
break ;
|
break ;
|
||||||
case ActiveMQBytesMessage::TYPE:
|
case ActiveMQBytesMessage::TYPE:
|
||||||
packetType->assign("ACTIVEMQ_BYTES_MESSAGE") ;
|
packetType->assign("ACTIVEMQ_BYTES_MESSAGE") ;
|
||||||
break ;
|
break ;
|
||||||
case ActiveMQStreamMessage::TYPE:
|
case ActiveMQStreamMessage::TYPE:
|
||||||
packetType->assign("ACTIVEMQ_STREAM_MESSAGE") ;
|
packetType->assign("ACTIVEMQ_STREAM_MESSAGE") ;
|
||||||
break ;
|
break ;
|
||||||
case ActiveMQMapMessage::TYPE:
|
case ActiveMQMapMessage::TYPE:
|
||||||
packetType->assign("ACTIVEMQ_MAP_MESSAGE") ;
|
packetType->assign("ACTIVEMQ_MAP_MESSAGE") ;
|
||||||
break ;
|
break ;
|
||||||
case ActiveMQQueue::TYPE:
|
case ActiveMQQueue::TYPE:
|
||||||
packetType->assign("ACTIVEMQ_QUEUE") ;
|
packetType->assign("ACTIVEMQ_QUEUE") ;
|
||||||
break ;
|
break ;
|
||||||
case ConsumerId::TYPE:
|
case ConsumerId::TYPE:
|
||||||
packetType->assign("CONSUMER_ID") ;
|
packetType->assign("CONSUMER_ID") ;
|
||||||
break ;
|
break ;
|
||||||
case ProducerId::TYPE:
|
case ProducerId::TYPE:
|
||||||
packetType->assign("PRODUCER_ID") ;
|
packetType->assign("PRODUCER_ID") ;
|
||||||
break ;
|
break ;
|
||||||
case MessageId::TYPE:
|
case MessageId::TYPE:
|
||||||
packetType->assign("MESSAGE_ID") ;
|
packetType->assign("MESSAGE_ID") ;
|
||||||
break ;
|
break ;
|
||||||
case LocalTransactionId::TYPE:
|
case LocalTransactionId::TYPE:
|
||||||
packetType->assign("LOCAL_TRANSACTION_ID") ;
|
packetType->assign("LOCAL_TRANSACTION_ID") ;
|
||||||
break ;
|
break ;
|
||||||
case MessageAck::TYPE:
|
case MessageAck::TYPE:
|
||||||
packetType->assign("ACTIVEMQ_MSG_ACK") ;
|
packetType->assign("ACTIVEMQ_MSG_ACK") ;
|
||||||
break ;
|
break ;
|
||||||
case MessageDispatch::TYPE:
|
case MessageDispatch::TYPE:
|
||||||
packetType->assign("ACTIVEMQ_MSG_DISPATCH") ;
|
packetType->assign("ACTIVEMQ_MSG_DISPATCH") ;
|
||||||
break ;
|
break ;
|
||||||
case Response::TYPE:
|
case Response::TYPE:
|
||||||
packetType->assign("RESPONSE") ;
|
packetType->assign("RESPONSE") ;
|
||||||
break ;
|
break ;
|
||||||
case ConsumerInfo::TYPE:
|
case ConsumerInfo::TYPE:
|
||||||
packetType->assign("CONSUMER_INFO") ;
|
packetType->assign("CONSUMER_INFO") ;
|
||||||
break ;
|
break ;
|
||||||
case ProducerInfo::TYPE:
|
case ProducerInfo::TYPE:
|
||||||
packetType->assign("PRODUCER_INFO") ;
|
packetType->assign("PRODUCER_INFO") ;
|
||||||
break;
|
break;
|
||||||
case TransactionInfo::TYPE:
|
case TransactionInfo::TYPE:
|
||||||
packetType->assign("TRANSACTION_INFO") ;
|
packetType->assign("TRANSACTION_INFO") ;
|
||||||
break ;
|
break ;
|
||||||
case BrokerInfo::TYPE:
|
case BrokerInfo::TYPE:
|
||||||
packetType->assign("BROKER_INFO") ;
|
packetType->assign("BROKER_INFO") ;
|
||||||
break ;
|
break ;
|
||||||
case ConnectionInfo::TYPE:
|
case ConnectionInfo::TYPE:
|
||||||
packetType->assign("CONNECTION_INFO") ;
|
packetType->assign("CONNECTION_INFO") ;
|
||||||
break ;
|
break ;
|
||||||
case SessionInfo::TYPE:
|
case SessionInfo::TYPE:
|
||||||
packetType->assign("SESSION_INFO") ;
|
packetType->assign("SESSION_INFO") ;
|
||||||
break ;
|
break ;
|
||||||
case RemoveSubscriptionInfo::TYPE:
|
case RemoveSubscriptionInfo::TYPE:
|
||||||
packetType->assign("DURABLE_UNSUBSCRIBE") ;
|
packetType->assign("DURABLE_UNSUBSCRIBE") ;
|
||||||
break ;
|
break ;
|
||||||
case IntegerResponse::TYPE:
|
case IntegerResponse::TYPE:
|
||||||
packetType->assign("INT_RESPONSE_RECEIPT_INFO") ;
|
packetType->assign("INT_RESPONSE_RECEIPT_INFO") ;
|
||||||
break ;
|
break ;
|
||||||
case WireFormatInfo::TYPE:
|
case WireFormatInfo::TYPE:
|
||||||
packetType->assign("WIRE_FORMAT_INFO") ;
|
packetType->assign("WIRE_FORMAT_INFO") ;
|
||||||
break ;
|
break ;
|
||||||
case RemoveInfo::TYPE:
|
case RemoveInfo::TYPE:
|
||||||
packetType->assign("REMOVE_INFO") ;
|
packetType->assign("REMOVE_INFO") ;
|
||||||
break ;
|
break ;
|
||||||
case KeepAliveInfo::TYPE:
|
case KeepAliveInfo::TYPE:
|
||||||
packetType->assign("KEEP_ALIVE") ;
|
packetType->assign("KEEP_ALIVE") ;
|
||||||
break ;
|
break ;
|
||||||
case ShutdownInfo::TYPE:
|
case ShutdownInfo::TYPE:
|
||||||
packetType->assign("SHUTDOWN") ;
|
packetType->assign("SHUTDOWN") ;
|
||||||
break ;
|
break ;
|
||||||
default:
|
default:
|
||||||
packetType->assign("UNDEFINED") ;
|
packetType->assign("UNDEFINED") ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
return packetType ;
|
return packetType ;
|
||||||
}
|
}
|
||||||
|
@ -1,56 +1,56 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
||||||
* applicable.
|
* applicable.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "TestListener.hpp"
|
#include "TestListener.hpp"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
TestListener::TestListener()
|
TestListener::TestListener()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
TestListener::~TestListener()
|
TestListener::~TestListener()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void TestListener::onMessage(p<IMessage> message)
|
void TestListener::onMessage(p<IMessage> message)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p<IBytesMessage> msg = p_dyncast<IBytesMessage> (message) ;
|
p<IBytesMessage> msg = p_dyncast<IBytesMessage> (message) ;
|
||||||
|
|
||||||
if( msg == NULL )
|
if( msg == NULL )
|
||||||
cout << "No message received!" << endl ;
|
cout << "No message received!" << endl ;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cout << "Received message with ID: " << msg->getJMSMessageID()->c_str() << endl ;
|
cout << "Received message with ID: " << msg->getJMSMessageID()->c_str() << endl ;
|
||||||
cout << " boolean: " << (msg->readBoolean() ? "true" : "false") << endl ;
|
cout << " boolean: " << (msg->readBoolean() ? "true" : "false") << endl ;
|
||||||
cout << " integer: " << msg->readInt() << endl ;
|
cout << " integer: " << msg->readInt() << endl ;
|
||||||
cout << " string: " << msg->readUTF()->c_str() << endl ;
|
cout << " string: " << msg->readUTF()->c_str() << endl ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( exception& e )
|
catch( exception& e )
|
||||||
{
|
{
|
||||||
cout << "OnMessage caught: " << e.what() << endl ;
|
cout << "OnMessage caught: " << e.what() << endl ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
||||||
* applicable.
|
* applicable.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#ifndef TestListener_hpp_
|
#ifndef TestListener_hpp_
|
||||||
#define TestListener_hpp_
|
#define TestListener_hpp_
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "cms/IMessage.hpp"
|
#include "cms/IMessage.hpp"
|
||||||
#include "cms/IBytesMessage.hpp"
|
#include "cms/IBytesMessage.hpp"
|
||||||
#include "cms/IMessageListener.hpp"
|
#include "cms/IMessageListener.hpp"
|
||||||
#include "ppr/util/ifr/p"
|
#include "ppr/util/ifr/p"
|
||||||
|
|
||||||
using namespace apache::cms;
|
using namespace apache::cms;
|
||||||
using namespace ifr;
|
using namespace ifr;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class TestListener : public IMessageListener
|
class TestListener : public IMessageListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestListener() ;
|
TestListener() ;
|
||||||
virtual ~TestListener() ;
|
virtual ~TestListener() ;
|
||||||
|
|
||||||
virtual void onMessage(p<IMessage> message) ;
|
virtual void onMessage(p<IMessage> message) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif /*TestListener_hpp_*/
|
#endif /*TestListener_hpp_*/
|
||||||
|
@ -1,192 +1,192 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
||||||
* applicable.
|
* applicable.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "cms/IConnectionFactory.hpp"
|
#include "cms/IConnectionFactory.hpp"
|
||||||
#include "cms/IConnection.hpp"
|
#include "cms/IConnection.hpp"
|
||||||
#include "cms/IDestination.hpp"
|
#include "cms/IDestination.hpp"
|
||||||
#include "cms/IMessageConsumer.hpp"
|
#include "cms/IMessageConsumer.hpp"
|
||||||
#include "cms/IMessageProducer.hpp"
|
#include "cms/IMessageProducer.hpp"
|
||||||
#include "cms/ISession.hpp"
|
#include "cms/ISession.hpp"
|
||||||
#include "cms/ITextMessage.hpp"
|
#include "cms/ITextMessage.hpp"
|
||||||
#include "activemq/ConnectionFactory.hpp"
|
#include "activemq/ConnectionFactory.hpp"
|
||||||
#include "activemq/Connection.hpp"
|
#include "activemq/Connection.hpp"
|
||||||
#include "activemq/command/ActiveMQTextMessage.hpp"
|
#include "activemq/command/ActiveMQTextMessage.hpp"
|
||||||
#include "ppr/TraceException.hpp"
|
#include "ppr/TraceException.hpp"
|
||||||
#include "ppr/util/MapItemHolder.hpp"
|
#include "ppr/util/MapItemHolder.hpp"
|
||||||
#include "ppr/net/Uri.hpp"
|
#include "ppr/net/Uri.hpp"
|
||||||
#include "ppr/util/ifr/p"
|
#include "ppr/util/ifr/p"
|
||||||
#include "TestListener.hpp"
|
#include "TestListener.hpp"
|
||||||
|
|
||||||
using namespace apache::activemq;
|
using namespace apache::activemq;
|
||||||
using namespace apache::activemq::command;
|
using namespace apache::activemq::command;
|
||||||
using namespace apache::cms;
|
using namespace apache::cms;
|
||||||
using namespace apache::ppr;
|
using namespace apache::ppr;
|
||||||
using namespace apache::ppr::net;
|
using namespace apache::ppr::net;
|
||||||
using namespace apache::ppr::util;
|
using namespace apache::ppr::util;
|
||||||
using namespace ifr;
|
using namespace ifr;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tests synchronous sending/receiving of a text message
|
* Tests synchronous sending/receiving of a text message
|
||||||
*/
|
*/
|
||||||
void testSyncTextMessage()
|
void testSyncTextMessage()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p<IConnectionFactory> factory ;
|
p<IConnectionFactory> factory ;
|
||||||
p<IConnection> connection ;
|
p<IConnection> connection ;
|
||||||
p<ISession> session ;
|
p<ISession> session ;
|
||||||
p<IQueue> queue ;
|
p<IQueue> queue ;
|
||||||
p<IMessageConsumer> consumer ;
|
p<IMessageConsumer> consumer ;
|
||||||
p<IMessageProducer> producer ;
|
p<IMessageProducer> producer ;
|
||||||
p<ITextMessage> reqMessage,
|
p<ITextMessage> reqMessage,
|
||||||
rspMessage ;
|
rspMessage ;
|
||||||
p<Uri> uri ;
|
p<Uri> uri ;
|
||||||
p<PropertyMap> props ;
|
p<PropertyMap> props ;
|
||||||
|
|
||||||
cout << "Connecting to ActiveMQ broker..." << endl ;
|
cout << "Connecting to ActiveMQ broker..." << endl ;
|
||||||
|
|
||||||
uri = new Uri("tcp://127.0.0.1:61616?trace=true&protocol=openwire") ;
|
uri = new Uri("tcp://127.0.0.1:61616?trace=true&protocol=openwire") ;
|
||||||
factory = new ConnectionFactory(uri) ;
|
factory = new ConnectionFactory(uri) ;
|
||||||
connection = factory->createConnection() ;
|
connection = factory->createConnection() ;
|
||||||
|
|
||||||
// Create session
|
// Create session
|
||||||
session = connection->createSession() ;
|
session = connection->createSession() ;
|
||||||
|
|
||||||
// Connect to queue
|
// Connect to queue
|
||||||
queue = session->getQueue("FOO.BAR") ;
|
queue = session->getQueue("FOO.BAR") ;
|
||||||
|
|
||||||
cout << "Using destination: " << queue->getQueueName()->c_str() << endl ;
|
cout << "Using destination: " << queue->getQueueName()->c_str() << endl ;
|
||||||
|
|
||||||
// Create a consumer and producer
|
// Create a consumer and producer
|
||||||
consumer = session->createConsumer(queue) ;
|
consumer = session->createConsumer(queue) ;
|
||||||
producer = session->createProducer(queue) ;
|
producer = session->createProducer(queue) ;
|
||||||
producer->setPersistent(true) ;
|
producer->setPersistent(true) ;
|
||||||
|
|
||||||
// Create a message
|
// Create a message
|
||||||
reqMessage = session->createTextMessage("Hello World!") ;
|
reqMessage = session->createTextMessage("Hello World!") ;
|
||||||
reqMessage->setJMSCorrelationID("abc") ;
|
reqMessage->setJMSCorrelationID("abc") ;
|
||||||
reqMessage->setJMSXGroupID("cheese") ;
|
reqMessage->setJMSXGroupID("cheese") ;
|
||||||
props = reqMessage->getProperties() ;
|
props = reqMessage->getProperties() ;
|
||||||
(*props)["someHeader"] = MapItemHolder( "James" ) ;
|
(*props)["someHeader"] = MapItemHolder( "James" ) ;
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
producer->send(reqMessage) ;
|
producer->send(reqMessage) ;
|
||||||
|
|
||||||
cout << "Waiting for asynchrounous receive message..." << endl ;
|
cout << "Waiting for asynchrounous receive message..." << endl ;
|
||||||
|
|
||||||
// Receive and wait for a message
|
// Receive and wait for a message
|
||||||
rspMessage = p_dyncast<ActiveMQTextMessage> (consumer->receive()) ;
|
rspMessage = p_dyncast<ActiveMQTextMessage> (consumer->receive()) ;
|
||||||
if( rspMessage == NULL )
|
if( rspMessage == NULL )
|
||||||
cout << "No message received!" << endl ;
|
cout << "No message received!" << endl ;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cout << "Received message with ID: " << rspMessage->getJMSMessageID()->c_str() << endl ;
|
cout << "Received message with ID: " << rspMessage->getJMSMessageID()->c_str() << endl ;
|
||||||
cout << " and text: " << rspMessage->getText()->c_str() << endl ;
|
cout << " and text: " << rspMessage->getText()->c_str() << endl ;
|
||||||
}
|
}
|
||||||
// Shutdown gracefully (including all attached sub-items, sessions, consumer/producer)
|
// Shutdown gracefully (including all attached sub-items, sessions, consumer/producer)
|
||||||
connection->close() ;
|
connection->close() ;
|
||||||
|
|
||||||
cout << "Disconnected from ActiveMQ broker" << endl ;
|
cout << "Disconnected from ActiveMQ broker" << endl ;
|
||||||
}
|
}
|
||||||
catch( TraceException& te )
|
catch( TraceException& te )
|
||||||
{
|
{
|
||||||
cout << "Caught: " << te.what() << endl ;
|
cout << "Caught: " << te.what() << endl ;
|
||||||
//cout << "Stack: " << e.getStackTrace() ;
|
//cout << "Stack: " << e.getStackTrace() ;
|
||||||
}
|
}
|
||||||
catch( exception& e )
|
catch( exception& e )
|
||||||
{
|
{
|
||||||
cout << "Caught: " << e.what() << endl ;
|
cout << "Caught: " << e.what() << endl ;
|
||||||
//cout << "Stack: " << e.getStackTrace() ;
|
//cout << "Stack: " << e.getStackTrace() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tests asynchronous sending/receiving of a binary message
|
* Tests asynchronous sending/receiving of a binary message
|
||||||
*/
|
*/
|
||||||
void testAsyncByteMessage()
|
void testAsyncByteMessage()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p<IConnectionFactory> factory ;
|
p<IConnectionFactory> factory ;
|
||||||
p<IConnection> connection ;
|
p<IConnection> connection ;
|
||||||
p<ISession> session ;
|
p<ISession> session ;
|
||||||
p<IQueue> queue ;
|
p<IQueue> queue ;
|
||||||
p<IMessageConsumer> consumer ;
|
p<IMessageConsumer> consumer ;
|
||||||
p<IMessageProducer> producer ;
|
p<IMessageProducer> producer ;
|
||||||
p<IBytesMessage> reqMessage,
|
p<IBytesMessage> reqMessage,
|
||||||
rspMessage ;
|
rspMessage ;
|
||||||
p<Uri> uri ;
|
p<Uri> uri ;
|
||||||
p<PropertyMap> props ;
|
p<PropertyMap> props ;
|
||||||
p<TestListener> listener ;
|
p<TestListener> listener ;
|
||||||
|
|
||||||
cout << "Connecting to ActiveMQ broker..." << endl ;
|
cout << "Connecting to ActiveMQ broker..." << endl ;
|
||||||
|
|
||||||
uri = new Uri("tcp://127.0.0.1:61616?trace=true&protocol=openwire") ;
|
uri = new Uri("tcp://127.0.0.1:61616?trace=true&protocol=openwire") ;
|
||||||
factory = new ConnectionFactory(uri) ;
|
factory = new ConnectionFactory(uri) ;
|
||||||
connection = factory->createConnection() ;
|
connection = factory->createConnection() ;
|
||||||
|
|
||||||
// Create session
|
// Create session
|
||||||
session = connection->createSession() ;
|
session = connection->createSession() ;
|
||||||
|
|
||||||
// Connect to queue
|
// Connect to queue
|
||||||
queue = session->getQueue("FOO.BAR") ;
|
queue = session->getQueue("FOO.BAR") ;
|
||||||
|
|
||||||
cout << "Using destination: " << queue->getQueueName()->c_str() << endl ;
|
cout << "Using destination: " << queue->getQueueName()->c_str() << endl ;
|
||||||
|
|
||||||
// Create producer and a asycnhrounous consumer
|
// Create producer and a asycnhrounous consumer
|
||||||
producer = session->createProducer(queue) ;
|
producer = session->createProducer(queue) ;
|
||||||
producer->setPersistent(true) ;
|
producer->setPersistent(true) ;
|
||||||
consumer = session->createConsumer(queue) ;
|
consumer = session->createConsumer(queue) ;
|
||||||
listener = new TestListener() ;
|
listener = new TestListener() ;
|
||||||
consumer->setMessageListener(listener) ;
|
consumer->setMessageListener(listener) ;
|
||||||
|
|
||||||
// Create binary message
|
// Create binary message
|
||||||
reqMessage = session->createBytesMessage() ;
|
reqMessage = session->createBytesMessage() ;
|
||||||
reqMessage->writeBoolean(true) ;
|
reqMessage->writeBoolean(true) ;
|
||||||
reqMessage->writeInt(3677490) ;
|
reqMessage->writeInt(3677490) ;
|
||||||
reqMessage->writeUTF("Hello Binary World!") ;
|
reqMessage->writeUTF("Hello Binary World!") ;
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
producer->send(reqMessage) ;
|
producer->send(reqMessage) ;
|
||||||
|
|
||||||
// Wait for asynchronous message
|
// Wait for asynchronous message
|
||||||
char c = getchar() ;
|
char c = getchar() ;
|
||||||
|
|
||||||
// Shutdown gracefully (including all attached sub-items, sessions, consumer/producer)
|
// Shutdown gracefully (including all attached sub-items, sessions, consumer/producer)
|
||||||
connection->close() ;
|
connection->close() ;
|
||||||
|
|
||||||
cout << "Disconnected from ActiveMQ broker" << endl ;
|
cout << "Disconnected from ActiveMQ broker" << endl ;
|
||||||
}
|
}
|
||||||
catch( TraceException& te )
|
catch( TraceException& te )
|
||||||
{
|
{
|
||||||
cout << "Caught: " << te.what() << endl ;
|
cout << "Caught: " << te.what() << endl ;
|
||||||
//cout << "Stack: " << e.getStackTrace() ;
|
//cout << "Stack: " << e.getStackTrace() ;
|
||||||
}
|
}
|
||||||
catch( exception& e )
|
catch( exception& e )
|
||||||
{
|
{
|
||||||
cout << "Caught: " << e.what() << endl ;
|
cout << "Caught: " << e.what() << endl ;
|
||||||
//cout << "Stack: " << e.getStackTrace() ;
|
//cout << "Stack: " << e.getStackTrace() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
testSyncTextMessage() ;
|
testSyncTextMessage() ;
|
||||||
testAsyncByteMessage() ;
|
testAsyncByteMessage() ;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user