@Override public ConnectionFactory createConnectionFactory(URI serverUri) { HashMap<String, Object> props = new HashMap<>(); props.put("host", UriUtils.extractHostFromUri(serverUri)); Integer port = UriUtils.extractPortFromUri(serverUri); if (port != null) { props.put("port", port); } TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), props); return HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration); }
public EngineMessageProducer(int clientID, String queueName, Session session) { this.clientID = clientID; this.queueName = queueName; this.session = session; try { // Step 1. Directly instantiate the JMS Queue object. queue = HornetQJMSClient.createQueue(queueName); if (log.isDebugEnabled()) { log.debug("Created queue named as: " + queueName); } // Step 6. Create a JMS Message Producer producer = session.createProducer(queue); if (log.isDebugEnabled()) { log.debug("Session created: " + session); } } catch (JMSException e) { log.error(e.toString(), e); } catch (Exception e) { log.error(e.toString(), e); // TODO: Restart connection...? } }
cf = HornetQJMSClient.createConnectionFactoryWithHA(groupConfig, cfConfig.getFactoryType()); cf = HornetQJMSClient.createConnectionFactoryWithoutHA(groupConfig, cfConfig.getFactoryType()); cf = HornetQJMSClient.createConnectionFactoryWithHA(cfConfig.getFactoryType(), configs); cf = HornetQJMSClient.createConnectionFactoryWithoutHA(cfConfig.getFactoryType(), configs);
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress()); final ServiceTarget serviceTarget = context.getServiceTarget(); // Do not pass the JNDI bindings to ActiveMQ but install them directly instead so that the // dependencies from the BinderServices to the JMSQueueService are not broken JMSTopicService jmsTopicService = JMSTopicService.installService(name, serviceName, serviceTarget); final ServiceName jmsTopicServiceName = JMSServices.getJmsTopicBaseServiceName(serviceName).append(name); for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) { BinderServiceUtil.installBinderService(serviceTarget, entry, jmsTopicService, jmsTopicServiceName); } List<String> legacyEntries = CommonAttributes.LEGACY_ENTRIES.unwrap(context, model); if (!legacyEntries.isEmpty()) { Topic legacyTopic = HornetQJMSClient.createTopic(name); for (String legacyEntry : legacyEntries) { BinderServiceUtil.installBinderService(serviceTarget, legacyEntry, legacyTopic); } } } }
connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(discoveryGroupConfiguration, factoryType); } else { connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(factoryType, transportConfigurations); connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(discoveryGroupConfiguration, factoryType); } else { connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(factoryType, transportConfigurations);
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress()); final ServiceTarget serviceTarget = context.getServiceTarget(); // Do not pass the JNDI bindings to ActiveMQ but install them directly instead so that the // dependencies from the BinderServices to the JMSQueueService are not broken JMSTopicService jmsTopicService = JMSTopicService.installService(name, serviceName, serviceTarget); final ServiceName jmsTopicServiceName = JMSServices.getJmsTopicBaseServiceName(serviceName).append(name); for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) { BinderServiceUtil.installBinderService(serviceTarget, entry, jmsTopicService, jmsTopicServiceName); } List<String> legacyEntries = CommonAttributes.LEGACY_ENTRIES.unwrap(context, model); if (!legacyEntries.isEmpty()) { Topic legacyTopic = HornetQJMSClient.createTopic(name); for (String legacyEntry : legacyEntries) { BinderServiceUtil.installBinderService(serviceTarget, legacyEntry, legacyTopic); } } } }
connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(discoveryGroupConfiguration, factoryType); } else { connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(factoryType, transportConfigurations); connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(discoveryGroupConfiguration, factoryType); } else { connectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(factoryType, transportConfigurations);
@Override public ConnectionFactory createConnectionFactory(URI serverUri) { HashMap<String, Object> props = new HashMap<>(); props.put("host", UriUtils.extractHostFromUri(serverUri)); Integer port = UriUtils.extractPortFromUri(serverUri); if (port != null) { props.put("port", port); } TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), props); return HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration); }
public void registerForReceivingMessages() { try { // Step 1. Directly instantiate the JMS Queue object. Queue queue = HornetQJMSClient.createQueue(systemQueueName); // Step 6. Create a JMS Message Producer producer = session.createProducer(queue); TextMessage message = session.createTextMessage("register:" + propertiesBean.getProperty("engine.unique.id")); // Step 8. Send the Message producer.send(message); log.debug("Registration message[{}] has been sent.", message.getText()); Thread.sleep(1000); // Execute receiver messageReceiver.setUp( "queue" + propertiesBean.getProperty("engine.unique.id"), session); // taskExecutorMessageProcess.execute(messageReceiver); messageReceiver.run(); receivingMessages = true; // TODO: Put a while loop here? As same as in the // "public void initiateConnection() {...}" ? } catch (Exception e) { log.error(e.toString(), e); } }
incompleteCF = HornetQJMSClient.createConnectionFactoryWithHA(factoryType); } else { incompleteCF = HornetQJMSClient.createConnectionFactoryWithoutHA(factoryType);
.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration);
try { queue = HornetQJMSClient.createQueue(queueName);
incompleteCF = HornetQJMSClient.createConnectionFactoryWithHA(factoryType); } else { incompleteCF = HornetQJMSClient.createConnectionFactoryWithoutHA(factoryType);
cf = (ConnectionFactory) HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration); ((HornetQConnectionFactory)cf).setUseGlobalPools(false);
Queue queue = HornetQJMSClient.createQueue(queueName);
protected ConnectionFactory createRemoteConnectionFactory(final Options<CreateContextOption> options) { //TODO: possibly cache the remote cf's? Map<String, Object> transportOpts = new HashMap<>(); transportOpts.put("host", options.getString(CreateContextOption.HOST)); transportOpts.put("port", options.getInt(CreateContextOption.PORT)); if (REMOTE_TYPE_WILDFLY.equals(options.getString(CreateContextOption.REMOTE_TYPE))) { transportOpts.put("http-upgrade-enabled", true); } TransportConfiguration config = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory", transportOpts); HornetQConnectionFactory hornetQcf = HornetQJMSClient .createConnectionFactoryWithoutHA(options.has(CreateContextOption.XA) ? JMSFactoryType.XA_CF : JMSFactoryType.CF, config); hornetQcf.setReconnectAttempts(options.getInt(CreateContextOption.RECONNECT_ATTEMPTS)); hornetQcf.setRetryInterval(options.getLong(CreateContextOption.RECONNECT_RETRY_INTERVAL)); hornetQcf.setRetryIntervalMultiplier(options.getDouble(CreateContextOption.RECONNECT_RETRY_INTERVAL_MULTIPLIER)); hornetQcf.setMaxRetryInterval(options.getLong(CreateContextOption.RECONNECT_MAX_RETRY_INTERVAL)); // We have to cast for HornetQ 2.3 - the factory object that is returned is both a HornetQConnectionFactory // and a javax.jms.ConnectionFactory, but HornetQConnectionFactory doesn't implement j.j.ConnectionFactory. // With HornetQ 2.4, this cast is redundant. return (ConnectionFactory)hornetQcf; }
QueueConnection connection = queueConnectionFactory.createQueueConnection(); Queue managementQueue = HornetQJMSClient.createQueue("hornetq.management"); QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); connection.start();
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress()); final ModelNode selectorNode = SELECTOR.resolveModelAttribute(context, model); final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean(); final String selector = selectorNode.isDefined() ? selectorNode.asString() : null; // Do not pass the JNDI bindings to ActiveMQ but install them directly instead so that the // dependencies from the BinderServices to the JMSQueueService are not broken Service<Queue> queueService = JMSQueueService.installService(name, serviceTarget, serviceName, selector, durable); final ServiceName jmsQueueServiceName = JMSServices.getJmsQueueBaseServiceName(serviceName).append(name); for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) { BinderServiceUtil.installBinderService(serviceTarget, entry, queueService, jmsQueueServiceName); } List<String> legacyEntries = CommonAttributes.LEGACY_ENTRIES.unwrap(context, model); if (!legacyEntries.isEmpty()) { Queue legacyQueue = HornetQJMSClient.createQueue(name); for (String legacyEntry : legacyEntries) { BinderServiceUtil.installBinderService(serviceTarget, legacyEntry, legacyQueue); } } } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress()); final ModelNode selectorNode = SELECTOR.resolveModelAttribute(context, model); final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean(); final String selector = selectorNode.isDefined() ? selectorNode.asString() : null; // Do not pass the JNDI bindings to ActiveMQ but install them directly instead so that the // dependencies from the BinderServices to the JMSQueueService are not broken Service<Queue> queueService = JMSQueueService.installService(name, serviceTarget, serviceName, selector, durable); final ServiceName jmsQueueServiceName = JMSServices.getJmsQueueBaseServiceName(serviceName).append(name); for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) { BinderServiceUtil.installBinderService(serviceTarget, entry, queueService, jmsQueueServiceName); } List<String> legacyEntries = CommonAttributes.LEGACY_ENTRIES.unwrap(context, model); if (!legacyEntries.isEmpty()) { Queue legacyQueue = HornetQJMSClient.createQueue(name); for (String legacyEntry : legacyEntries) { BinderServiceUtil.installBinderService(serviceTarget, legacyEntry, legacyQueue); } } } }