com.ibm.mq.jms.MQConnectionFactory Java Examples

The following examples show how to use com.ibm.mq.jms.MQConnectionFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MQConnectionFactoryConfiguration.java    From mq-jms-spring with Apache License 2.0 8 votes vote down vote up
@Bean
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "true", matchIfMissing = true)
public CachingConnectionFactory cachingJmsConnectionFactory(MQConfigurationProperties properties,
    ObjectProvider<List<MQConnectionFactoryCustomizer>> factoryCustomizers, JmsProperties jmsProperties) {

  JmsProperties.Cache cacheProperties = jmsProperties.getCache();

  MQConnectionFactory wrappedConnectionFactory = createConnectionFactory(properties, factoryCustomizers);

  CachingConnectionFactory connectionFactory = new CachingConnectionFactory(wrappedConnectionFactory);
  connectionFactory.setCacheConsumers(cacheProperties.isConsumers());
  connectionFactory.setCacheProducers(cacheProperties.isProducers());
  connectionFactory.setSessionCacheSize(cacheProperties.getSessionCacheSize());

  return connectionFactory;
}
 
Example #2
Source File: WebSphereMQTarget.java    From jmet with MIT License 6 votes vote down vote up
public void init() throws InitException {

        try {
            MQConnectionFactory realfactory = new MQConnectionFactory();
            realfactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
            realfactory.setHostName(getHost());
            realfactory.setPort(getPort());
            realfactory.setQueueManager(getQueueManager());
            realfactory.setChannel(getChannel());

            factory = realfactory;
            connection = factory.createConnection(getUser(), getPassword());
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            dest = (getDestType() == DestType.QUEUE) ? session.createQueue(getDestination()) : session.createTopic(getDestination());
            producer = session.createProducer(dest);
            connection.start();
        } catch (JMSException e) {
            throw new InitException(e.fillInStackTrace());
        }

    }
 
Example #3
Source File: MQConnectionFactoryConfiguration.java    From mq-jms-spring with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "false")
public MQConnectionFactory jmsConnectionFactory(MQConfigurationProperties properties,
    ObjectProvider<List<MQConnectionFactoryCustomizer>> factoryCustomizers) {

  return createConnectionFactory(properties, factoryCustomizers);
}
 
Example #4
Source File: MQCommandProcessor.java    From perf-harness with MIT License 5 votes vote down vote up
public final void buildJMSResource() {
	
	try {
		cf = new MQConnectionFactory();
		configureMQConnectionFactory((MQConnectionFactory) cf);
		connection = cf.createConnection();
		connection.start();
		
		insession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
		outsession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
		
		inQueue = new MQQueue(Config.parms.getString("cmd_inq"));
		outQueue = new MQQueue(Config.parms.getString("cmd_outq"));
		
		((MQQueue) outQueue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
		
		messageConsumer = insession.createConsumer(inQueue);
		messageProducer = outsession.createProducer(outQueue);
		
	} catch (JMSException e) {
		Log.logger.log(Level.SEVERE,
				"Error connecting Command Processor to WebSphereMQ", e);
		return;
	}
	
}
 
Example #5
Source File: MQCommandProcessor.java    From perf-harness with MIT License 5 votes vote down vote up
/**
 * Apply vendor-specific settings for building up a connection factory to
 * WMQ.
 * 
 * @param cf
 * @throws JMSException
 */
protected void configureMQConnectionFactory(MQConnectionFactory cf)
		throws JMSException {

	// always client bindings
	cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
	cf.setHostName(Config.parms.getString("cmd_jh"));
	cf.setPort(Config.parms.getInt("cmd_p"));
	cf.setChannel(Config.parms.getString("cmd_jc"));

	cf.setQueueManager(Config.parms.getString("cmd_jb"));

}
 
Example #6
Source File: WebSphereMQ.java    From perf-harness with MIT License 5 votes vote down vote up
public void createTopicConnectionFactory(String name) throws Exception {
	
	if ( usingJNDI ) {
		TopicConnectionFactory tcf = new MQTopicConnectionFactory();
		configureMQConnectionFactory((MQConnectionFactory)tcf);
		try {
			getInitialContext().bind( name, tcf );
		} catch ( NameAlreadyBoundException e ) {
			// swallowed
		}
	} else {
		// No op
	}
	
}
 
Example #7
Source File: WebSphereMQ.java    From perf-harness with MIT License 5 votes vote down vote up
public void createQueueConnectionFactory(String name) throws Exception {
	
	if ( usingJNDI ) {
		QueueConnectionFactory qcf = new MQQueueConnectionFactory();
		configureMQConnectionFactory((MQConnectionFactory)qcf);
		try {
			getInitialContext().bind( name, qcf );
		} catch ( NameAlreadyBoundException e ) {
			// swallowed
		}
	} else {
		// No op
	}
	
}
 
Example #8
Source File: WebSphereMQ.java    From perf-harness with MIT License 5 votes vote down vote up
public void createConnectionFactory(String name) throws Exception {
	
	if ( usingJNDI ) {
		ConnectionFactory cf = new MQConnectionFactory();
		configureMQConnectionFactory( (MQConnectionFactory)cf );
		try {
			getInitialContext().bind( name, cf );
		} catch ( NameAlreadyBoundException e ) {
			// swallowed
		}
	} else {
		// No op
	}
	
}
 
Example #9
Source File: WebSphereMQ.java    From perf-harness with MIT License 5 votes vote down vote up
/**
 * Create a new vendor-specific ConnectionFactory (or delegate to JNDI if that is has been selected).
 */	
public synchronized ConnectionFactory lookupConnectionFactory(String name) throws JMSException, NamingException {
	
	if ( usingJNDI ) {
		return super.lookupConnectionFactory(name);
	} else {
		MQConnectionFactory cf = new MQConnectionFactory();
		configureMQConnectionFactory( cf );
		return cf;
	} // end if cf==null

}
 
Example #10
Source File: WMB.java    From perf-harness with MIT License 5 votes vote down vote up
public TopicConnectionFactory lookupTopicConnectionFactory( String name )
		throws JMSException, NamingException {

	if (usingJNDI || usingMQ) {
		return super.lookupTopicConnectionFactory(name);
	} else {
		MQTopicConnectionFactory tcf = new MQTopicConnectionFactory();
		configureWBIMBConnectionFactory((MQConnectionFactory) tcf);
		return tcf;
	} // end if tcf==null

}
 
Example #11
Source File: MQConnectionFactoryConfiguration.java    From mq-jms-spring with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "stop")
@ConditionalOnProperty(prefix = "ibm.mq.pool", name = "enabled", havingValue = "true", matchIfMissing = false)
public JmsPoolConnectionFactory pooledJmsConnectionFactory(MQConfigurationProperties properties,
    ObjectProvider<List<MQConnectionFactoryCustomizer>> factoryCustomizers) {

  MQConnectionFactory connectionFactory = createConnectionFactory(properties, factoryCustomizers);

  return create(connectionFactory, properties.getPool());
}
 
Example #12
Source File: MQConnectionFactoryFactory.java    From mq-jms-spring with Apache License 2.0 4 votes vote down vote up
private void customize(MQConnectionFactory connectionFactory) {
  for (MQConnectionFactoryCustomizer factoryCustomizer : this.factoryCustomizers) {
    factoryCustomizer.customize(connectionFactory);
  }
}
 
Example #13
Source File: MQConnectionFactoryFactory.java    From mq-jms-spring with Apache License 2.0 4 votes vote down vote up
private <T extends MQConnectionFactory> T createConnectionFactoryInstance(Class<T> factoryClass)
    throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
  return factoryClass.getConstructor().newInstance();
}
 
Example #14
Source File: MQConnectionFactoryConfiguration.java    From mq-jms-spring with Apache License 2.0 4 votes vote down vote up
private static MQConnectionFactory createConnectionFactory(MQConfigurationProperties properties,
    ObjectProvider<List<MQConnectionFactoryCustomizer>> factoryCustomizers) {
  return new MQConnectionFactoryFactory(properties, factoryCustomizers.getIfAvailable()).createConnectionFactory(MQConnectionFactory.class);
}
 
Example #15
Source File: MQXAConnectionFactoryConfiguration.java    From mq-jms-spring with Apache License 2.0 4 votes vote down vote up
@Bean
public ConnectionFactory nonXaJmsConnectionFactory(MQConfigurationProperties properties, ObjectProvider<List<MQConnectionFactoryCustomizer>> factoryCustomizers) {
  return new MQConnectionFactoryFactory(properties, factoryCustomizers.getIfAvailable()).createConnectionFactory(MQConnectionFactory.class);
}
 
Example #16
Source File: WMB.java    From perf-harness with MIT License 3 votes vote down vote up
/**
 * Provide additional functionality for WMB connection factories.
 */
@SuppressWarnings("deprecation")
private void configureWBIMBConnectionFactory(MQConnectionFactory cf) throws JMSException {

		//Set common attributes i.e. version,port,hostname and buffersize.			
		//Set the broker version we will use version 2 is suitable for argo brokers
		cf.setBrokerVersion(brokerVersion);
		cf.setHostName(Config.parms.getString("jh"));
		cf.setPort(Config.parms.getInt("jp"));
		if (bufferSize > 0)
		{
			cf.setMaxBufferSize(bufferSize);
		}

		if (transport.equals("ip"))
		{
			System.out.println("Using transport type MQJMS_TP_DIRECT_TCPIP");
			cf.setTransportType(WMQConstants.WMQ_CM_DIRECT_TCPIP);
		}
		else if (transport.equals("ipmc"))
		{
			System.out.println("Using transport type MQJMS_TP_DIRECT_TCPIP, Multicast Enabled");
			cf.setTransportType(WMQConstants.WMQ_CM_DIRECT_TCPIP);
			cf.setMulticast(WMQConstants.RTT_MULTICAST_ENABLED);
		}
		else if (transport.equals("ipmcr"))
		{
			System.out.println("Using transport type MQJMS_TP_DIRECT_TCPIP, Multicast Enabled & Reliable");
			cf.setTransportType(WMQConstants.WMQ_CM_DIRECT_TCPIP);
			cf.setMulticast(WMQConstants.RTT_MULTICAST_RELIABLE);
		}
		else if (transport.equals("ipmcn"))
		{
			System.out.println("Using transport type MQJMS_TP_DIRECT_TCPIP, Multicast Enabled & NOT Reliable");
			cf.setTransportType(WMQConstants.WMQ_CM_DIRECT_TCPIP);
			cf.setMulticast(WMQConstants.RTT_MULTICAST_NOT_RELIABLE);
		}
		else if (transport.equals("mqb"))
		{
			//Place holder statement incase we ever need to do anything for this transport over and above what the MQ plugin already does.
			cf.setBrokerQueueManager(Config.parms.getString("jb"));
		}
		else if (transport.equals("mqc"))
		{
			//Place holder statement incase we ever need to do anything for this transport over and above what the MQ plugin already does.
			cf.setBrokerQueueManager(Config.parms.getString("jb"));
		}
		else
		{
			System.out.println("Invalid transport type");
			System.exit(1);
		}
		

}
 
Example #17
Source File: MQConnectionFactoryCustomizer.java    From mq-jms-spring with Apache License 2.0 2 votes vote down vote up
/**
 * Customize the {@link MQConnectionFactory}.
 * @param factory the factory to customize
 */
void customize(MQConnectionFactory factory);