| <div class="wiki-content maincontent"><p>The Apache.NMS.ActiveMQ client provides some additional features beyond the standard NMS API.  One such feature is the ability to delete a given destination on the Broker.  This can be useful during testing when you want to start the test with a destination in a known state, empty or otherwise.  You can delete the destination and then the next send to that destination would recreate it at the Broker side.  Deleting a destination is as simple as the following:</p><p> </p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Delete a destination</b></div><div class="codeContent panelContent pdl"> |
| <script class="brush: c#; gutter: true; theme: Eclipse" type="syntaxhighlighter"><![CDATA[protected static void DeleteDestination() |
| { |
| IConnectionFactory factory = new ConnectionFactory(ReplaceEnvVar(connectionURI)); |
| using (Connection connection = factory.CreateConnection() as Connection) |
| { |
| using (ISession session = connection.CreateSession()) |
| { |
| IQueue queue = session.GetQueue(testQueueName); |
| try |
| { |
| connection.DeleteDestination(queue); |
| } |
| catch |
| { |
| } |
| } |
| } |
| } ]]></script> |
| </div></div><p> </p><p> </p></div> |
| |