List of usage examples for javax.jms TemporaryTopic getTopicName
String getTopicName() throws JMSException;
From source file:org.ct.amq.jdbc.security.JdbcAuthenticationPluginTest.java
public void testTempDestinations() throws Exception { Connection conn = factory.createConnection("guest", "password"); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); String name = "org.apache.activemq:BrokerName=localhost,Type=TempTopic"; try {/* www . j av a2s. c o m*/ conn.start(); TemporaryTopic temp = sess.createTemporaryTopic(); name += ",Destination=" + temp.getTopicName().replaceAll(":", "_"); fail("Should have failed creating a temp topic"); } catch (Exception ignore) { } ObjectName objName = new ObjectName(name); TopicViewMBean mbean = (TopicViewMBean) broker.getManagementContext().newProxyInstance(objName, TopicViewMBean.class, true); try { System.out.println(mbean.getName()); fail("Shouldn't have created a temp topic"); } catch (Exception ignore) { } }
From source file:net.timewalker.ffmq4.listeners.ClientProcessor.java
private CreateTemporaryTopicResponse processCreateTemporaryTopic(CreateTemporaryTopicQuery query) throws JMSException { LocalSession session = lookupSession(query); TemporaryTopic topic = session.createTemporaryTopic(); CreateTemporaryTopicResponse response = new CreateTemporaryTopicResponse(); response.setTopicName(topic.getTopicName()); return response; }
From source file:org.openanzo.combus.bayeux.BridgeConnectionManager.java
/** * Sets up state for connecting a single Bayeux client to the BayeuxJMSBridge. * //ww w. j a v a 2s.co m * @param clientId * the Bayeux client id. * @return true if client was connected. false if there was already a connection for the client. */ protected boolean connectClient(String clientId, MessageListener listener, AnzoPrincipal principal) throws JMSException { // checks if connection already exists, create topic and client state, add to maps. boolean ret = false; boolean clientAlreadyConnected = false; mapLock.lock(); try { clientAlreadyConnected = clientIdToClientState.containsKey(clientId); } finally { mapLock.unlock(); } if (!clientAlreadyConnected) { // We don't have a temporary topic for this client yet so we'll create one. // We make sure to do this while NOT holding the mapLock to avoid deadlocks // (like http://www.openanzo.org/projects/openanzo/ticket/286). This // means that it's possible, in rare cases, that we could create a temp topic which we'll // have to just throw out immediately but there's not much harm in that. TemporaryTopic topic = session.createTemporaryTopic(); String tempDestinationId = topic.getTopicName(); MessageConsumer consumer = session.createConsumer(topic); consumer.setMessageListener(listener); boolean destroyNewJMSState = false; mapLock.lock(); try { if (clientIdToClientState.containsKey(clientId)) { // Some other thread seems to have connected this client while we were busy creating // JMS topics, etc. That's okay, we'll just close the topics we created since they aren't needed anymore. // But we don't want to destroy them while holding the mapLock, so we'll just mark a boolean so that they // are deleted after releasing the lock. destroyNewJMSState = true; } else { ClientState state = new ClientState(principal, topic, clientId, consumer); tempDestinationToClientState.put(tempDestinationId, state); clientIdToClientState.put(clientId, state); ret = true; } } finally { mapLock.unlock(); if (destroyNewJMSState) { consumer.close(); topic.delete(); } } } return ret; }
From source file:org.openanzo.combus.bayeux.BridgeConnectionManager.java
/** * Find the Bayeux username and clientId to which messages sent to the given topic should be relayed. Returns null if no such mapping could be found. * /*w w w. j a v a 2 s . co m*/ * @param topic * @return a username and clientId pair. * @throws JMSException */ protected Pair<String, String> findBayeuxReplyChannelForTopic(TemporaryTopic topic) throws JMSException { String destination = topic.getTopicName(); Pair<String, String> ret = null; mapLock.lock(); try { ClientState state = tempDestinationToClientState.get(destination); if (state != null) { ret = new Pair<String, String>(state.principal.getName(), state.clientId); } } finally { mapLock.unlock(); } return ret; }