[
https://issues.apache.org/activemq/browse/AMQCPP-166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=41240#action_41240
]
Timothy Bish commented on AMQCPP-166:
-------------------------------------
I added the following test to the integration suite in both trunk and in the
2.1.3 release code and it passes without error using the 5.0 broker.
void OpenwireSimpleTest::testMapMessageSend() {
try {
TestSupport
testSupport(IntegrationCommon::getInstance().getOpenwireURL(),
cms::Session::CLIENT_ACKNOWLEDGE );
testSupport.initialize();
if( IntegrationCommon::debug ) {
cout << "Starting activemqcms test (sending "
<< IntegrationCommon::defaultMsgCount
<< " messages per type and sleeping "
<< IntegrationCommon::defaultDelay
<< " milli-seconds) ...\n"
<< endl;
}
// Create CMS Object for Comms
cms::Session* session = testSupport.getSession();
cms::Queue* queue = session->createQueue( Guid::createGUIDString() );
cms::MessageConsumer* consumer = session->createConsumer( queue );
cms::MessageProducer* producer = session->createProducer( queue );
unsigned char byteValue = 'A';
char charValue = 'B';
bool booleanValue = true;
short shortValue = 2048;
int intValue = 655369;
long long longValue = 0xFFFFFFFF00000000ULL;
float floatValue = 45.6545f;
double doubleValue = 654564.654654;
std::string stringValue = "The test string";
cms::MapMessage* mapMessage = session->createMapMessage();
mapMessage->setString( "stringKey", stringValue );
mapMessage->setBoolean( "boolKey", booleanValue );
mapMessage->setByte( "byteKey", byteValue );
mapMessage->setChar( "charKey", charValue );
mapMessage->setShort( "shortKey", shortValue );
mapMessage->setInt( "intKey", intValue );
mapMessage->setLong( "longKey", longValue );
mapMessage->setFloat( "floatKey", floatValue );
mapMessage->setDouble( "doubleKey", doubleValue );
std::vector<unsigned char> bytes;
bytes.push_back( 65 );
bytes.push_back( 66 );
bytes.push_back( 67 );
bytes.push_back( 68 );
bytes.push_back( 69 );
mapMessage->setBytes( "bytesKey", bytes );
// Send some text messages
producer->send( mapMessage );
delete mapMessage;
cms::Message* message = consumer->receive( 1500 );
CPPUNIT_ASSERT( message != NULL );
cms::MapMessage* recvMapMessage = dynamic_cast<MapMessage*>( message );
CPPUNIT_ASSERT( recvMapMessage != NULL );
CPPUNIT_ASSERT( recvMapMessage->getString( "stringKey" ) == stringValue
);
CPPUNIT_ASSERT( recvMapMessage->getBoolean( "boolKey" ) == booleanValue
);
CPPUNIT_ASSERT( recvMapMessage->getByte( "byteKey" ) == byteValue );
CPPUNIT_ASSERT( recvMapMessage->getChar( "charKey" ) == charValue );
CPPUNIT_ASSERT( recvMapMessage->getShort( "shortKey" ) == shortValue );
CPPUNIT_ASSERT( recvMapMessage->getInt( "intKey" ) == intValue );
CPPUNIT_ASSERT( recvMapMessage->getLong( "longKey" ) == longValue );
CPPUNIT_ASSERT( recvMapMessage->getFloat( "floatKey" ) == floatValue );
CPPUNIT_ASSERT( recvMapMessage->getDouble( "doubleKey" ) == doubleValue
);
CPPUNIT_ASSERT( recvMapMessage->getBytes( "bytesKey" ) == bytes );
delete message;
if( IntegrationCommon::debug ) {
printf("Shutting Down\n" );
}
delete producer;
delete consumer;
delete queue;
}
AMQ_CATCH_RETHROW( ActiveMQException )
}
> MapMessage does not send mapped fields
> --------------------------------------
>
> Key: AMQCPP-166
> URL: https://issues.apache.org/activemq/browse/AMQCPP-166
> Project: ActiveMQ C++ Client
> Issue Type: Bug
> Components: Openwire
> Affects Versions: 2.1.3
> Environment: 32-bit XP client with client compiled under VS 2005,
> ActiveMQ v5.0 is running on a 32-bit Windows 2003 server.
> Reporter: Thomas Johnson
> Assignee: Timothy Bish
>
> Modified the vs2005-activemq-example's HelloWorldProducer to use a map
> message:
> MapMessage *message=session->createMapMessage();
> message->setInt("MsgNum",ix);
>
> message->setString("Thread",threadIdStr.c_str());
> producer->send( message );
> and the HelloWorldConsumer to receive it:
> const MapMessage * mapMessage=
> dynamic_cast<const MapMessage *>(message);
> if (mapMessage!=NULL) {
> int num=mapMessage->getInt("MsgNum");
> printf("Msg #%d from thread
> %s\n",num,mapMessage->getString("Thread").c_str());
> } else {
> printf("Not a map message\n");
> }
> The getInt with Msgnum throw a field not in map exception. After closer
> inspection, the map was empty. Also, while not an expert in the code, but I
> tried tracing it through the producer->send and as far as I could tell, the
> map was never marshalled.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.