@Override public Connection createConnection() throws JMSException { return cf.createTopicConnection(); } @Override
/** * This implementation delegates to the {@code createTopicConnection(username, password)} * method of the target TopicConnectionFactory, passing in the specified user credentials. * If the specified username is empty, it will simply delegate to the standard * {@code createTopicConnection()} method of the target ConnectionFactory. * @param username the username to use * @param password the password to use * @return the Connection * @see javax.jms.TopicConnectionFactory#createTopicConnection(String, String) * @see javax.jms.TopicConnectionFactory#createTopicConnection() */ protected TopicConnection doCreateTopicConnection( @Nullable String username, @Nullable String password) throws JMSException { ConnectionFactory target = obtainTargetConnectionFactory(); if (!(target instanceof TopicConnectionFactory)) { throw new javax.jms.IllegalStateException("'targetConnectionFactory' is not a TopicConnectionFactory"); } TopicConnectionFactory queueFactory = (TopicConnectionFactory) target; if (StringUtils.hasLength(username)) { return queueFactory.createTopicConnection(username, password); } else { return queueFactory.createTopicConnection(); } }
@Override public TopicConnection createTopicConnection(String username, String password) throws JMSException { ConnectionFactory target = obtainTargetConnectionFactory(); if (target instanceof TopicConnectionFactory) { return ((TopicConnectionFactory) target).createTopicConnection(username, password); } else { Connection con = target.createConnection(username, password); if (!(con instanceof TopicConnection)) { throw new javax.jms.IllegalStateException("'targetConnectionFactory' is not a TopicConnectionFactory"); } return (TopicConnection) con; } }
@Override public TopicConnection createTopicConnection() throws JMSException { ConnectionFactory target = obtainTargetConnectionFactory(); if (target instanceof TopicConnectionFactory) { return ((TopicConnectionFactory) target).createTopicConnection(); } else { Connection con = target.createConnection(); if (!(con instanceof TopicConnection)) { throw new javax.jms.IllegalStateException("'targetConnectionFactory' is not a TopicConnectionFactory"); } return (TopicConnection) con; } }
/** * Create a JMS Connection via this template's ConnectionFactory. * @return the new JMS Connection * @throws javax.jms.JMSException if thrown by JMS API methods */ protected Connection doCreateConnection() throws JMSException { ConnectionFactory cf = getTargetConnectionFactory(); if (Boolean.FALSE.equals(this.pubSubMode) && cf instanceof QueueConnectionFactory) { return ((QueueConnectionFactory) cf).createQueueConnection(); } else if (Boolean.TRUE.equals(this.pubSubMode) && cf instanceof TopicConnectionFactory) { return ((TopicConnectionFactory) cf).createTopicConnection(); } else { return obtainTargetConnectionFactory().createConnection(); } }
@Override public TopicConnection createTopicConnection(String username, String password) throws JMSException { ConnectionFactory target = getTargetConnectionFactory(); if (!(target instanceof TopicConnectionFactory)) { throw new javax.jms.IllegalStateException("'targetConnectionFactory' is no TopicConnectionFactory"); } TopicConnection targetConnection = ((TopicConnectionFactory) target).createTopicConnection(username, password); return (TopicConnection) getTransactionAwareConnectionProxy(targetConnection); }
@Override public TopicConnection createTopicConnection() throws JMSException { ConnectionFactory target = getTargetConnectionFactory(); if (!(target instanceof TopicConnectionFactory)) { throw new javax.jms.IllegalStateException("'targetConnectionFactory' is no TopicConnectionFactory"); } TopicConnection targetConnection = ((TopicConnectionFactory) target).createTopicConnection(); return (TopicConnection) getTransactionAwareConnectionProxy(targetConnection); }
public JMSSink( String tcfBindingName, String topicBindingName, String username, String password) { try { Context ctx = new InitialContext(); TopicConnectionFactory topicConnectionFactory; topicConnectionFactory = (TopicConnectionFactory) lookup(ctx, tcfBindingName); TopicConnection topicConnection = topicConnectionFactory.createTopicConnection(username, password); topicConnection.start(); TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = (Topic)ctx.lookup(topicBindingName); TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic); topicSubscriber.setMessageListener(this); } catch(JMSException e) { logger.error("Could not read JMS message.", e); } catch(NamingException e) { logger.error("Could not read JMS message.", e); } catch(RuntimeException e) { logger.error("Could not read JMS message.", e); } }
@Override public TopicConnection createTopicConnection(String userName, String password) throws JMSException { checkTopicConnectionFactory(); TopicConnectionFactory qcf = (TopicConnectionFactory) delegate; return TracingConnection.create(qcf.createTopicConnection(userName, password), jmsTracing); }
@Override public TopicConnection createTopicConnection() throws JMSException { checkTopicConnectionFactory(); TopicConnectionFactory qcf = (TopicConnectionFactory) delegate; return TracingConnection.create(qcf.createTopicConnection(), jmsTracing); }
if (outboundUsername != null) { newConnection = outboundTopicConnectionFactory .createTopicConnection(outboundUsername, outboundPassword); } else { newConnection = outboundTopicConnectionFactory.createTopicConnection(); if (outboundUsername != null) { newConnection = outboundTopicConnectionFactory .createTopicConnection(outboundUsername, outboundPassword); } else { newConnection = outboundTopicConnectionFactory.createTopicConnection();
LogLog.debug("About to create TopicConnection."); if(userName != null) { topicConnection = topicConnectionFactory.createTopicConnection(userName, password); } else { topicConnection = topicConnectionFactory.createTopicConnection();
if (localUsername != null) { newConnection = localTopicConnectionFactory .createTopicConnection(localUsername, localPassword); } else { newConnection = localTopicConnectionFactory.createTopicConnection(); if (localUsername != null) { newConnection = localTopicConnectionFactory. createTopicConnection(localUsername, localPassword); } else { newConnection = localTopicConnectionFactory.createTopicConnection();
@Test public void testWithTopicConnectionFactoryAndJms102Usage() throws JMSException { TopicConnectionFactory cf = mock(TopicConnectionFactory.class); TopicConnection con = mock(TopicConnection.class); given(cf.createTopicConnection()).willReturn(con); SingleConnectionFactory scf = new SingleConnectionFactory(cf); Connection con1 = scf.createTopicConnection(); Connection con2 = scf.createTopicConnection(); con1.start(); con2.start(); con1.close(); con2.close(); scf.destroy(); // should trigger actual close verify(con).start(); verify(con).stop(); verify(con).close(); verifyNoMoreInteractions(con); }
conn = connFactory.createTopicConnection(); } else { final String user = dataMap.getString(JmsHelper.JMS_USER); .getString(JmsHelper.JMS_PASSWORD); conn = connFactory.createTopicConnection(user, password);
TopicSession nonTxSession = mock(TopicSession.class); given(cf.createTopicConnection()).willReturn(con); given(con.createTopicSession(true, Session.AUTO_ACKNOWLEDGE)).willReturn(txSession); given(txSession.getTransacted()).willReturn(true);
public JMSTopicSink(String tcfBindingName, String topicBindingName, String username, String password) { try { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); env.put(Context.PROVIDER_URL, "tcp://localhost:61616"); Context ctx = new InitialContext(env); TopicConnectionFactory topicConnectionFactory; topicConnectionFactory = (TopicConnectionFactory) lookup(ctx, tcfBindingName); System.out.println("Topic Cnx Factory found"); Topic topic = (Topic) ctx.lookup(topicBindingName); System.out.println("Topic found: " + topic.getTopicName()); TopicConnection topicConnection = topicConnectionFactory .createTopicConnection(username, password); System.out.println("Topic Connection created"); TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic); topicSubscriber.setMessageListener(this); topicConnection.start(); System.out.println("Topic Connection started"); } catch (Exception e) { logger.error("Could not read JMS message.", e); } }
public JMSSink( String tcfBindingName, String topicBindingName, String username, String password) { try { Context ctx = new InitialContext(); TopicConnectionFactory topicConnectionFactory; topicConnectionFactory = (TopicConnectionFactory) lookup(ctx, tcfBindingName); TopicConnection topicConnection = topicConnectionFactory.createTopicConnection(username, password); topicConnection.start(); TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = (Topic)ctx.lookup(topicBindingName); TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic); topicSubscriber.setMessageListener(this); } catch(JMSException e) { logger.error("Could not read JMS message.", e); } catch(NamingException e) { logger.error("Could not read JMS message.", e); } catch(RuntimeException e) { logger.error("Could not read JMS message.", e); } }
this.topicConnection = topicConnectionFactory.createTopicConnection( userName, password); } else { this.topicConnection = topicConnectionFactory.createTopicConnection();
LogLog.debug("About to create TopicConnection."); if(userName != null) { topicConnection = topicConnectionFactory.createTopicConnection(userName, password); } else { topicConnection = topicConnectionFactory.createTopicConnection();