You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by MathxH <br...@foxmail.com> on 2015/11/06 07:45:38 UTC
CMS cannot receive the file content from JMS create BlobMessage
contains file content
System Enviroment:
1.ActiveMQ broker version is 5.9.1
2.CMS version is 3.9.0 ---------------this version support BlobMessage
3.JMS version is 1.1
4. (1)java version is 1.8.0_40
(2)java TM SE rumtime enviroment (build 1.8.0_40-b26)
(3)java HotSpot b4-bit server VM (build 25.40-b25,mixed mode)
***************************************************************
Here is details:
I need to transfer big files between different language clients (JMS and
CMS) with ActiveMQ,then, the issue comes to show:
I use JMS create BlobMessage to send it with file.(producer) and use CMS
receive this BlobMessage(consumer) , CMS cannot get the file content. I am
pretty sure that BlobMessage has sent to broker successfully and CMS can
receive this blobmessage (because I can get related Message Properties from
JMS),BUT!!, CMS cannot get file Content.
JMS code snippet as follows:
*
BlobMessage blobMessage = session.createBlobMessage(file);
blobMessage.setStringProperty("FILE.NAME", file.getName());
blobMessage.setLongProperty("FILE.SIZE", file.length());
System.out.println("start send file:" + file.getName() + ",file
size:"
+ file.length() + " bytes");
producer.send(blobMessage);
System.out.println("send complete:" + file.getName());
producer.close();
session.close();
connection.close();
*
CMS code snippet as follows:
*
void onMessage( const Message* message ) {
commands::ActiveMQBlobMessage* blobMessage =
dynamic_cast<commands::ActiveMQBlobMessage*>(message);
if (blobMessage)
{
commands::Message* cmdMsg = (commands::Message*)blobMessage;
if (cmdMsg)
{
std::vector<unsigned char> properties =
cmdMsg->getMarshalledProperties();
LIST_PROPERTIES lstProperties;
int nErr = ParseProperties(properties, lstProperties);
if (nErr == 0)
{
// get related properties
getMessageHeader(lstProperties, header, nFileSize);
if (nFileSize > 0)
{
// get file content,but vector fileContent size is always
zero
std::vector<unsigned char> fileContent;
fileContent = blobMessage->getContent();
}
}
}
}
}
*
--
View this message in context: http://activemq.2283324.n4.nabble.com/CMS-cannot-receive-the-file-content-from-JMS-create-BlobMessage-contains-file-content-tp4703724.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: CMS cannot receive the file content from JMS create BlobMessage
contains file content
Posted by Timothy Bish <ta...@gmail.com>.
On 11/06/2015 01:45 AM, MathxH wrote:
> System Enviroment:
>
> 1.ActiveMQ broker version is 5.9.1
> 2.CMS version is 3.9.0 ---------------this version support BlobMessage
> 3.JMS version is 1.1
>
>
> 4. (1)java version is 1.8.0_40
> (2)java TM SE rumtime enviroment (build 1.8.0_40-b26)
> (3)java HotSpot b4-bit server VM (build 25.40-b25,mixed mode)
>
> ***************************************************************
>
> Here is details:
>
> I need to transfer big files between different language clients (JMS and
> CMS) with ActiveMQ,then, the issue comes to show:
> I use JMS create BlobMessage to send it with file.(producer) and use CMS
> receive this BlobMessage(consumer) , CMS cannot get the file content. I am
> pretty sure that BlobMessage has sent to broker successfully and CMS can
> receive this blobmessage (because I can get related Message Properties from
> JMS),BUT!!, CMS cannot get file Content.
>
> JMS code snippet as follows:
> *
> BlobMessage blobMessage = session.createBlobMessage(file);
>
> blobMessage.setStringProperty("FILE.NAME", file.getName());
>
> blobMessage.setLongProperty("FILE.SIZE", file.length());
>
> System.out.println("start send file:" + file.getName() + ",file
> size:"
>
> + file.length() + " bytes");
>
> producer.send(blobMessage);
>
> System.out.println("send complete:" + file.getName());
>
> producer.close();
>
> session.close();
>
> connection.close();
> *
>
> CMS code snippet as follows:
> *
> void onMessage( const Message* message ) {
>
> commands::ActiveMQBlobMessage* blobMessage =
> dynamic_cast<commands::ActiveMQBlobMessage*>(message);
>
> if (blobMessage)
> {
> commands::Message* cmdMsg = (commands::Message*)blobMessage;
> if (cmdMsg)
> {
> std::vector<unsigned char> properties =
> cmdMsg->getMarshalledProperties();
> LIST_PROPERTIES lstProperties;
> int nErr = ParseProperties(properties, lstProperties);
> if (nErr == 0)
> {
> // get related properties
> getMessageHeader(lstProperties, header, nFileSize);
>
>
> if (nFileSize > 0)
> {
> // get file content,but vector fileContent size is always
> zero
> std::vector<unsigned char> fileContent;
> fileContent = blobMessage->getContent();
> }
> }
> }
> }
> }
> *
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/CMS-cannot-receive-the-file-content-from-JMS-create-BlobMessage-contains-file-content-tp4703724.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Copied from last reply:
The CMS client does not do the work of downloading the blob message
content from the defined remote URL as things like HTTP and FTP are not
built into C++, you need to bake your own solution for how the content
is downloaded from the remote source.
--
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.redhat.com
twitter: @tabish121
blog: http://timbish.blogspot.com/