List of usage examples for org.springframework.jms.core JmsTemplate JmsTemplate
public JmsTemplate(ConnectionFactory connectionFactory)
From source file:org.nebulaframework.grid.cluster.manager.services.jobs.unbounded.UnboundedJobProcessor.java
/** * Creates the {@code JmsTemplate} used to write * tasks to TaskQueue.//from w w w .j a v a 2 s . c o m */ private void initializeTaskWritier() { this.jmsTemplate = new JmsTemplate(connectionFactory); }
From source file:org.wallerlab.yoink.config.BatchConfig.java
/** * Standard JMS template for sending request. * @return -{@link org.springframework.jms.core.JmsTemplate} *//* w w w. j a va 2s. c o m*/ @Bean JmsOperations jmsRequestTemplate() { JmsTemplate jmsRequestTemplate = new JmsTemplate(connectionFactory()); jmsRequestTemplate.setDefaultDestinationName("yoink-request"); jmsRequestTemplate.setReceiveTimeout(2000l); return jmsRequestTemplate; }
From source file:org.wallerlab.yoink.config.BatchConfig.java
/** * Standard JMS template, used to respond. * @return -{@link org.springframework.jms.core.JmsTemplate} *///from w w w . ja v a2s. c om @Bean JmsOperations jmsResponseTemplate() { JmsTemplate jmsResponseTemplate = new JmsTemplate(connectionFactory()); jmsResponseTemplate.setDefaultDestinationName("yoink-response"); jmsResponseTemplate.setReceiveTimeout(2000l); return jmsResponseTemplate; }
From source file:org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.java
public synchronized void activate() throws Exception { super.activate(); if (template == null) { if (isJms102()) { template = new JmsTemplate102(getConnectionFactory(), isPubSubDomain()); } else {/*from www . j a v a2 s . c o m*/ template = new JmsTemplate(getConnectionFactory()); } } if (store == null && !stateless) { if (storeFactory == null) { storeFactory = new MemoryStoreFactory(); } store = storeFactory.open(getService().toString() + getEndpoint()); } }
From source file:org.nebulaframework.grid.cluster.node.services.job.execution.TaskExecutor.java
/** * Initializes the ResultWriter ({@code JMSTemplate}) for this * {@code TaskExecutor}. Configures the {@code JmsTemplate} to send * messages to the {@code ResultQueue} as its default destination. *///from w ww . j a v a 2 s . com private void initializeResultQueueWriter() { jmsTemplate = new JmsTemplate(connectionFactory); jmsTemplate.setDefaultDestinationName(JMSNamingSupport.getResultQueueName(jobId)); }
From source file:ca.uhn.hunit.iface.AbstractJmsInterfaceImpl.java
/** * {@inheritDoc}// w ww . java 2 s. co m */ @Override protected void doStart() throws InterfaceWontStartException { try { myConnectionFactory = (ConnectionFactory) myConstructor .newInstance(myConstructorArgsTableModel.getArgArray()); } catch (IllegalArgumentException e1) { throw new InterfaceWontStartException(this, e1.getMessage()); } catch (InstantiationException e1) { throw new InterfaceWontStartException(this, e1.getMessage()); } catch (IllegalAccessException e1) { throw new InterfaceWontStartException(this, e1.getMessage()); } catch (InvocationTargetException e1) { throw new InterfaceWontStartException(this, e1.getMessage()); } myConnectionFactory = new JmsConnectionFactory(myConnectionFactory, myUsername, myPassword); myJmsTemplate = new JmsTemplate(myConnectionFactory); myJmsTemplate.setReceiveTimeout(1000); myJmsTemplate.setPubSubDomain(myPubSubDomain); }
From source file:org.genemania.connector.JmsEngineConnector.java
public void setConnectionFactory(ConnectionFactory cf) { this.jmsTemplate = new JmsTemplate(cf); int timeout = Integer.parseInt(ApplicationConfig.getInstance() .getProperty(org.genemania.broker.Constants.CONFIG_PROPERTIES.CLIENT_TIMEOUT)); this.jmsTemplate.setReceiveTimeout(1000 * timeout); }
From source file:org.openengsb.ports.jms.JMSIncomingPort.java
public void start() { simpleMessageListenerContainer = createListenerContainer(receive, new MessageListener() { @Override//from w ww .ja va 2 s . co m public void onMessage(Message message) { LOGGER.trace("JMS-message recieved. Checking if the type is supported"); if (!(message instanceof TextMessage)) { LOGGER.debug("Received JMS-message is not type of text message."); return; } LOGGER.trace("Received a text message and start parsing"); TextMessage textMessage = (TextMessage) message; String textContent = extractTextFromMessage(textMessage); HashMap<String, Object> metadata = new HashMap<String, Object>(); String result = null; try { LOGGER.debug("starting filterchain for incoming message"); result = (String) getFilterChainToUse().filter(textContent, metadata); } catch (Exception e) { LOGGER.error("an error occured when processing the filterchain", e); result = ExceptionUtils.getStackTrace(e); } Destination replyQueue; final String correlationID; try { if (message.getJMSCorrelationID() == null) { correlationID = message.getJMSMessageID(); } else { correlationID = message.getJMSCorrelationID(); } replyQueue = message.getJMSReplyTo(); } catch (JMSException e) { LOGGER.warn("error when getting destination queue or correlationid from client message: {}", e); return; } if (replyQueue == null) { LOGGER.warn("no replyTo destination specifyed could not send response"); return; } new JmsTemplate(connectionFactory).convertAndSend(replyQueue, result, new MessagePostProcessor() { @Override public Message postProcessMessage(Message message) throws JMSException { message.setJMSCorrelationID(correlationID); return message; } }); } private String extractTextFromMessage(TextMessage textMessage) { try { return textMessage.getText(); } catch (JMSException e) { throw new IllegalStateException("Couldn't extract text from jms message", e); } } }); simpleMessageListenerContainer.start(); }
From source file:org.openengsb.ports.jms.JMSPortTest.java
@Before public void setup() { System.setProperty("org.apache.activemq.default.directory.prefix", tempFolder.getRoot().getAbsolutePath() + "/"); setupKeys();/*from w ww .ja v a2s .c o m*/ String num = UUID.randomUUID().toString(); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost" + num); jmsTemplate = new JmsTemplate(connectionFactory); jmsTemplateFactory = new JMSTemplateFactory() { @Override public SimpleMessageListenerContainer createMessageListenerContainer() { return simpleMessageListenerConainer; } @Override public JmsTemplate createJMSTemplate(DestinationUrl destinationUrl) { return jmsTemplate; } }; simpleMessageListenerConainer = new SimpleMessageListenerContainer(); incomingPort = new JMSIncomingPort(); incomingPort.setFactory(jmsTemplateFactory); incomingPort.setConnectionFactory(connectionFactory); RequestHandlerImpl requestHandlerImpl = new RequestHandlerImpl(); requestHandlerImpl.setUtilsService(new DefaultOsgiUtilsService(bundleContext)); handler = requestHandlerImpl; TestInterface mock2 = mock(TestInterface.class); registerServiceViaId(mock2, "test", TestInterface.class); when(mock2.method(anyString(), anyInt(), any(TestClass.class))).thenReturn(new TestClass("test")); Map<String, String> metaData = Maps.newHashMap(ImmutableMap.of("serviceId", "test")); MethodCall methodCall = new MethodCall("method", new Object[] { "123", 5, new TestClass("test"), }, metaData); call = new MethodCallMessage(methodCall, "123"); call.setDestination("host?receive"); MethodResult result = new MethodResult(new TestClass("test")); result.setMetaData(metaData); methodReturn = new MethodResultMessage(result, "123"); Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(Constants.PROVIDED_CLASSES_KEY, Password.class.getName()); props.put(Constants.DELEGATION_CONTEXT_KEY, org.openengsb.core.api.Constants.DELEGATION_CONTEXT_CREDENTIALS); registerService(new ClassProviderImpl(bundle, Sets.newHashSet(Password.class.getName())), props, ClassProvider.class); DefaultSecurityManager securityManager = new DefaultSecurityManager(); securityManager.setAuthenticator(new Authenticator() { @Override public AuthenticationInfo authenticate(AuthenticationToken authenticationToken) throws org.apache.shiro.authc.AuthenticationException { return new SimpleAuthenticationInfo(authenticationToken.getPrincipal(), authenticationToken.getCredentials(), "openengsb"); } }); SecurityUtils.setSecurityManager(securityManager); }
From source file:org.openmrs.event.EventEngine.java
private synchronized void initializeIfNeeded() { if (jmsTemplate == null) { log.info("creating connection factory"); String dataDirectory = new File(OpenmrsUtil.getApplicationDataDirectory(), "activemq-data") .getAbsolutePath();/* w w w . j av a2 s .c o m*/ try { dataDirectory = URLEncoder.encode(dataDirectory, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Failed to encode URI", e); } String brokerURL = "vm://localhost?broker.persistent=true&broker.dataDirectory=" + dataDirectory; ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(brokerURL); connectionFactory = new SingleConnectionFactory(cf); // or CachingConnectionFactory ? jmsTemplate = new JmsTemplate(connectionFactory); } else { log.trace("messageListener already defined"); } }