[rabbitmq-discuss] Not Able to keep messages persistent
Abhishek Kona
abhishek.kona at gmail.com
Fri Sep 3 10:40:54 BST 2010
Ok my bad.
When I use transactional mode, (I commit after the operation), the
messages are persisted.
When I do a basicpublish without any transactions the messages are not
being persisted (the messages are sent to the queues for sure)
This is the exact problem.
The exact code is:
this.channel = connection.createChannel();
this.channel.txSelect();
Item item = new Item();
item.setData(data);
item.setCreationTime(Calendar.getInstance().getTimeInMillis());
item.setItemId(QUtils.genID());
item.setQueueName(queuename);
String itemStringRep = QUtils.ItemToString(item);
BasicProperties bp = new AMQP.BasicProperties();
bp.setTimestamp(Calendar.getInstance().getTime());
bp.setDeliveryMode(2);
try
{
this.channel.queueDeclarePassive(queuename);
this.channel.basicPublish("default_exchange", queuename,
bp, itemStringRep.getBytes());
}
catch (IOException e)
{
throw new QueueServiceException("Enqueue failed: [ Queue
does not Exists ] " + "[ " + e + " ] ");
}
try
{
this.channel.txCommit();
}
When I remove the txCommit and txSelect. the messages are not persisted.
Abhishek Kona
On 03/09/10 1:34 PM, David Wragg wrote:
> Hi Abhishek,
>
> Abhishek Kona<abhishek.kona at gmail.com> writes:
>> When I am using Transaction Commit, the messages are persisted but
>> without the transaction commits, the messages are not persistent.
>>
>> I am guessing the issue is the messages are not persisted as soon as
>> they are received. But at some time later on by the RabbitMQ.
>> Is this the issue.
> If you put an AMQP channel into transactional mode, and you don't commit
> the transaction, then it's as if the messages were never published. Not
> only will the messages not be persisted, but the messages won't even go
> into the message queues until you commit the transaction.
>
> Is this consistent with what you are seeing? If not, could you provide
> a full test program to demonstrate you problem?
>
> David
>
More information about the rabbitmq-discuss
mailing list