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

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