Added little snippet to example for wiki

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@380777 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-02-24 18:44:43 +00:00
parent eb52635994
commit 0461466367
1 changed files with 5 additions and 11 deletions

View File

@ -31,16 +31,13 @@ namespace openwire_dotnet
{ {
Console.WriteLine("About to connect to ActiveMQ"); Console.WriteLine("About to connect to ActiveMQ");
// START SNIPPET: example
IConnectionFactory factory = new ConnectionFactory("localhost", 61616); IConnectionFactory factory = new ConnectionFactory("localhost", 61616);
Console.WriteLine("Worked!");
using (IConnection connection = factory.CreateConnection()) using (IConnection connection = factory.CreateConnection())
{ {
Console.WriteLine("Created a connection!"); Console.WriteLine("Created a connection!");
ISession session = connection.CreateSession(); ISession session = connection.CreateSession();
Console.WriteLine("Created a session: " + session);
IDestination destination = session.GetQueue("FOO.BAR"); IDestination destination = session.GetQueue("FOO.BAR");
Console.WriteLine("Using destination: " + destination); Console.WriteLine("Using destination: " + destination);
@ -50,25 +47,22 @@ namespace openwire_dotnet
IMessageProducer producer = session.CreateProducer(destination); IMessageProducer producer = session.CreateProducer(destination);
string expected = "Hello World!"; string expected = "Hello World!";
ITextMessage request = session.CreateTextMessage(expected); ITextMessage request = session.CreateTextMessage(expected);
producer.Send(request); producer.Send(request);
Console.WriteLine("### About to receive message...");
ActiveMQTextMessage message = (ActiveMQTextMessage) consumer.Receive(); ActiveMQTextMessage message = (ActiveMQTextMessage) consumer.Receive();
if (message == null) if (message == null)
{ {
Console.WriteLine("### No message!!"); Console.WriteLine("No message received!");
} }
else else
{ {
Console.WriteLine("### Received message: " + message + " of type: " + message.GetType());
String actual = message.Text; String actual = message.Text;
Console.WriteLine("Received message with text: " + actual);
Console.WriteLine("### Message text is: " + actual);
} }
} }
// END SNIPPET: example
} }
catch (Exception e) catch (Exception e)
{ {