/** * Set the name of this message endpoint. Populated with the bean name * automatically when defined within Spring's bean factory. */ @Override public void setBeanName(String beanName) { this.endpointFactory.setBeanName(beanName); }
/** * Creates a concrete JMS message endpoint, internal to this factory. */ @Override protected AbstractMessageEndpoint createEndpointInternal() throws UnavailableException { return new JmsMessageEndpoint(); }
public boolean isReplyPubSubDomain() { if (this.replyPubSubDomain != null) { return this.replyPubSubDomain; } else { return isPubSubDomain(); } }
private void assertDefaultJcaConfig(JmsMessageEndpointManager container) { assertEquals(this.messageConverter, container.getMessageConverter()); assertEquals(this.destinationResolver, container.getDestinationResolver()); JmsActivationSpecConfig config = container.getActivationSpecConfig(); assertNotNull(config); assertEquals(Session.DUPS_OK_ACKNOWLEDGE, config.getAcknowledgeMode()); assertEquals(true, config.isPubSubDomain()); assertEquals(new QosSettings(1, 7, 5000), container.getReplyQosSettings()); assertEquals(true, config.isSubscriptionDurable()); assertEquals("client-1234", config.getClientId()); }
@Test public void pubSubDomainCustomForReply() { JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsActivationSpecConfig config = new JmsActivationSpecConfig(); config.setPubSubDomain(true); config.setReplyPubSubDomain(false); endpoint.setActivationSpecConfig(config); assertEquals(true, endpoint.isPubSubDomain()); assertEquals(false, endpoint.isReplyPubSubDomain()); }
@Test public void activeMQResourceAdapterSetup() { activationSpecConfig.setAcknowledgeMode(Session.SESSION_TRANSACTED); JmsActivationSpecFactory activationSpecFactory = new DefaultJmsActivationSpecFactory(); StubActiveMQActivationSpec spec = (StubActiveMQActivationSpec) activationSpecFactory.createActivationSpec( new StubActiveMQResourceAdapter(), activationSpecConfig); assertEquals(5, spec.getMaxSessions()); assertEquals(3, spec.getMaxMessagesPerSessions()); assertTrue(spec.isUseRAManagedTransaction()); }
@Override public void afterPropertiesSet() throws ResourceException { if (getResourceAdapter() == null) { throw new IllegalArgumentException("Property 'resourceAdapter' is required"); } if (this.messageListenerSet) { setMessageEndpointFactory(this.endpointFactory); } if (this.activationSpecConfig != null) { setActivationSpec( this.activationSpecFactory.createActivationSpec(getResourceAdapter(), this.activationSpecConfig)); } super.afterPropertiesSet(); }
@Test public void customReplyQosSettings() { JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsActivationSpecConfig config = new JmsActivationSpecConfig(); QosSettings settings = new QosSettings(1, 3, 5); config.setReplyQosSettings(settings); endpoint.setActivationSpecConfig(config); assertNotNull(endpoint.getReplyQosSettings()); assertEquals(1, endpoint.getReplyQosSettings().getDeliveryMode()); assertEquals(3, endpoint.getReplyQosSettings().getPriority()); assertEquals(5, endpoint.getReplyQosSettings().getTimeToLive()); }
/** * Set the DestinationResolver to use for resolving destination names * into the JCA 1.5 ActivationSpec "destination" property. * <p>If not specified, destination names will simply be passed in as Strings. * If specified, destination names will be resolved into Destination objects first. * <p>Note that a DestinationResolver is usually specified on the JmsActivationSpecFactory * (see {@link StandardJmsActivationSpecFactory#setDestinationResolver}). This is simply * a shortcut for parameterizing the default JmsActivationSpecFactory; it will replace * any custom JmsActivationSpecFactory that might have been set before. * @see StandardJmsActivationSpecFactory#setDestinationResolver */ public void setDestinationResolver(DestinationResolver destinationResolver) { DefaultJmsActivationSpecFactory factory = new DefaultJmsActivationSpecFactory(); factory.setDestinationResolver(destinationResolver); this.activationSpecFactory = factory; }
@Override public boolean isPubSubDomain() { JmsActivationSpecConfig config = getActivationSpecConfig(); if (config != null) { return config.isPubSubDomain(); } throw new IllegalStateException("Could not determine pubSubDomain - no activation spec config is set"); }
@Override @Nullable public MessageConverter getMessageConverter() { JmsActivationSpecConfig config = getActivationSpecConfig(); if (config != null) { return config.getMessageConverter(); } return null; }
@Override public boolean isReplyPubSubDomain() { JmsActivationSpecConfig config = getActivationSpecConfig(); if (config != null) { return config.isReplyPubSubDomain(); } throw new IllegalStateException("Could not determine reply pubSubDomain - no activation spec config is set"); }
@Override @Nullable public QosSettings getReplyQosSettings() { JmsActivationSpecConfig config = getActivationSpecConfig(); if (config != null) { return config.getReplyQosSettings(); } throw new IllegalStateException("Could not determine reply qosSettings - no activation spec config is set"); } }
/** * Create an empty container instance. */ protected JmsMessageEndpointManager createContainerInstance() { return new JmsMessageEndpointManager(); }
/** * Set the JMS MessageListener for this endpoint. * <p>This is a shortcut for configuring a dedicated JmsMessageEndpointFactory. * @see JmsMessageEndpointFactory#setMessageListener */ public void setMessageListener(MessageListener messageListener) { this.endpointFactory.setMessageListener(messageListener); this.messageListenerSet = true; }
/** * Set the XA transaction manager to use for wrapping endpoint * invocations, enlisting the endpoint resource in each such transaction. * <p>The passed-in object may be a transaction manager which implements * Spring's {@link org.springframework.transaction.jta.TransactionFactory} * interface, or a plain {@link javax.transaction.TransactionManager}. * <p>If no transaction manager is specified, the endpoint invocation * will simply not be wrapped in an XA transaction. Consult your * resource provider's ActivationSpec documentation for the local * transaction options of your particular provider. * <p>This is a shortcut for configuring a dedicated JmsMessageEndpointFactory. * @see JmsMessageEndpointFactory#setTransactionManager */ public void setTransactionManager(Object transactionManager) { this.endpointFactory.setTransactionManager(transactionManager); }
/** * Return the JMS MessageListener for this endpoint. */ public MessageListener getMessageListener() { return this.endpointFactory.getMessageListener(); }
@Override @Nullable public DestinationResolver getDestinationResolver() { if (this.activationSpecFactory instanceof StandardJmsActivationSpecFactory) { return ((StandardJmsActivationSpecFactory) this.activationSpecFactory).getDestinationResolver(); } return null; }
@Test public void isPubSubDomainWithTopic() { JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsActivationSpecConfig config = new JmsActivationSpecConfig(); config.setPubSubDomain(true); endpoint.setActivationSpecConfig(config); assertEquals(true, endpoint.isPubSubDomain()); assertEquals(true, endpoint.isReplyPubSubDomain()); }
@Test public void isPubSubDomainWithQueue() { JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsActivationSpecConfig config = new JmsActivationSpecConfig(); config.setPubSubDomain(false); endpoint.setActivationSpecConfig(config); assertEquals(false, endpoint.isPubSubDomain()); assertEquals(false, endpoint.isReplyPubSubDomain()); }