[rabbitmq-discuss] System.ObjectDisposedException
Derek Johnston
derekejohnston at gmail.com
Wed Feb 19 16:35:28 GMT 2014
try that ..... no luck - surely this works in .net?
var connection = connectionFactory.CreateConnection();
var channel = connection.CreateModel();
// Create a new, durable exchange
channel.ExchangeDeclare("sample-ex", ExchangeType.Direct, true,
false, null);
// Create a new, durable queue
channel.QueueDeclare("sample-queue", true, false, false, null);
// Bind the queue to the exchange
channel.QueueBind("sample-queue", "sample-ex",
"optional-routing-key");
// Set up message properties
var properties = channel.CreateBasicProperties();
properties.DeliveryMode = 2; // Messages are persistent and will
survive a server restart
// Ready to start publishing
// The message to publish can be anything that can be serialized to
a byte array,
// such as a serializable object, an ID for an entity, or simply a
string
var encoding = new UTF8Encoding();
for (var i = 0; i < 1; i++)
{
var msg = string.Format("This is message derek #yyy{0}?", i +
1);
var msgBytes = encoding.GetBytes(msg);
channel.BasicPublish("sample-ex", "optional-routing-key",
false, false, properties, msgBytes);
}
channel.Close();
connection.Close();
Console.WriteLine("Messages published");
Console.ReadKey(true);
On Wed, Feb 19, 2014 at 4:30 PM, Michael Klishin <mklishin at gopivotal.com>wrote:
>
> On 19 Feb 2014, at 20:22, Derek Johnston <derekejohnston at gmail.com> wrote:
>
> > is there a work around?
>
> Try closing connection manually instead of using `using`?
>
> MK
>
> Software Engineer, Pivotal/RabbitMQ
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140219/f83340a8/attachment.html>
More information about the rabbitmq-discuss
mailing list