You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Sean Beck <se...@gmail.com> on 2013/06/11 20:53:43 UTC

libstomp C message being read without me reading it

I am using the C library libstomp to send a message to my broker. It sends
my message, but it also dequeues my message. I don't want it to do that.

I have removed my error checking to decrease verbosity.

Here is my setup for the connection:

apr_status_t rc;

rc = stomp_connect(&connection, "127.0.0.1", 61613, p);

// connect frame
frame.command = "CONNECT";
frame.headers = NULL;
frame.body = NULL;
rc = stomp_write(connection, &frame, p);

// now subscribe
frame.command = "SUB";
frame.headers = apr_hash_make(p);
apr_hash_set(frame.headers, "destination", APR_HASH_KEY_STRING,
"queuename");
rc = stomp_write(connection, &frame, p);

Here is my message sending:

frame.command = "SEND";
// no need to setup headers for queue bc done in init
// allocate some mem for body
frame.body = apr_palloc(r->pool,filename_size);
strcpy(frame.body, filename);

apr_status_t rc;
rc = stomp_write(connection, &frame, r->pool);


I am not calling stomp_read anywhere so I am unsure as to why my message is
being dequeued as soon as it is enqueued.

Thanks

Re: libstomp C message being read without me reading it

Posted by Sean Beck <se...@gmail.com>.
Awesome thanks


On Tue, Jun 11, 2013 at 1:05 PM, Timothy Bish <ta...@gmail.com> wrote:

> On 06/11/2013 02:53 PM, Sean Beck wrote:
>
>> I am using the C library libstomp to send a message to my broker. It sends
>> my message, but it also dequeues my message. I don't want it to do that.
>>
>> I have removed my error checking to decrease verbosity.
>>
>> Here is my setup for the connection:
>>
>> apr_status_t rc;
>>
>> rc = stomp_connect(&connection, "127.0.0.1", 61613, p);
>>
>> // connect frame
>> frame.command = "CONNECT";
>> frame.headers = NULL;
>> frame.body = NULL;
>> rc = stomp_write(connection, &frame, p);
>>
>> // now subscribe
>> frame.command = "SUB";
>> frame.headers = apr_hash_make(p);
>> apr_hash_set(frame.headers, "destination", APR_HASH_KEY_STRING,
>> "queuename");
>> rc = stomp_write(connection, &frame, p);
>>
>> Here is my message sending:
>>
>> frame.command = "SEND";
>> // no need to setup headers for queue bc done in init
>> // allocate some mem for body
>> frame.body = apr_palloc(r->pool,filename_**size);
>> strcpy(frame.body, filename);
>>
>> apr_status_t rc;
>> rc = stomp_write(connection, &frame, r->pool);
>>
>>
>> I am not calling stomp_read anywhere so I am unsure as to why my message
>> is
>> being dequeued as soon as it is enqueued.
>>
>> Thanks
>>
>>  I'm guessing the client subscribes with ack mode auto ack, and the
> default prefetch is used so a Message will be dispatched to your client as
> soon you subscribe.  You can subscribe with a different ack mode like
> client ack and then the message is only removed on the broker side once you
> ack it.
>
> You don't need to subscribe to send a message so not subscribing would
> also solve your issue.
>
> --
> Tim Bish
> Sr Software Engineer | RedHat Inc.
> tim.bish@redhat.com | www.fusesource.com | www.redhat.com
> skype: tabish121 | twitter: @tabish121
> blog: http://timbish.blogspot.com/
>
> www.camelone.org : The open source integration conference:
>
>

Re: libstomp C message being read without me reading it

Posted by Timothy Bish <ta...@gmail.com>.
On 06/11/2013 02:53 PM, Sean Beck wrote:
> I am using the C library libstomp to send a message to my broker. It sends
> my message, but it also dequeues my message. I don't want it to do that.
>
> I have removed my error checking to decrease verbosity.
>
> Here is my setup for the connection:
>
> apr_status_t rc;
>
> rc = stomp_connect(&connection, "127.0.0.1", 61613, p);
>
> // connect frame
> frame.command = "CONNECT";
> frame.headers = NULL;
> frame.body = NULL;
> rc = stomp_write(connection, &frame, p);
>
> // now subscribe
> frame.command = "SUB";
> frame.headers = apr_hash_make(p);
> apr_hash_set(frame.headers, "destination", APR_HASH_KEY_STRING,
> "queuename");
> rc = stomp_write(connection, &frame, p);
>
> Here is my message sending:
>
> frame.command = "SEND";
> // no need to setup headers for queue bc done in init
> // allocate some mem for body
> frame.body = apr_palloc(r->pool,filename_size);
> strcpy(frame.body, filename);
>
> apr_status_t rc;
> rc = stomp_write(connection, &frame, r->pool);
>
>
> I am not calling stomp_read anywhere so I am unsure as to why my message is
> being dequeued as soon as it is enqueued.
>
> Thanks
>
I'm guessing the client subscribes with ack mode auto ack, and the 
default prefetch is used so a Message will be dispatched to your client 
as soon you subscribe.  You can subscribe with a different ack mode like 
client ack and then the message is only removed on the broker side once 
you ack it.

You don't need to subscribe to send a message so not subscribing would 
also solve your issue.

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/

www.camelone.org : The open source integration conference: