org.springframework.jms.support.destination.DestinationResolutionException Java Examples

The following examples show how to use org.springframework.jms.support.destination.DestinationResolutionException. 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: JmsMessagingTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void convertDestinationResolutionExceptionOnSend() {
	Destination destination = new Destination() {};
	willThrow(DestinationResolutionException.class).given(this.jmsTemplate).send(eq(destination), any());

	assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() ->
			this.messagingTemplate.send(destination, createTextMessage()));
}
 
Example #2
Source File: JmsMessagingTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void convertDestinationResolutionExceptionOnReceive() {
	Destination destination = new Destination() {};
	willThrow(DestinationResolutionException.class).given(this.jmsTemplate).receive(destination);

	assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() ->
			this.messagingTemplate.receive(destination));
}
 
Example #3
Source File: JmsMessagingTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void convertInvalidDestinationExceptionOnSendAndReceiveWithName() {
	willThrow(InvalidDestinationException.class).given(this.jmsTemplate).sendAndReceive(eq("unknownQueue"), any());

	assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() ->
			this.messagingTemplate.sendAndReceive("unknownQueue", createTextMessage()));
}
 
Example #4
Source File: JmsMessagingTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void convertInvalidDestinationExceptionOnSendAndReceive() {
	Destination destination = new Destination() {};
	willThrow(InvalidDestinationException.class).given(this.jmsTemplate).sendAndReceive(eq(destination), any());

	assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() ->
			this.messagingTemplate.sendAndReceive(destination, createTextMessage()));
}
 
Example #5
Source File: JmsMessagingTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void convertDestinationResolutionExceptionOnSend() {
	Destination destination = new Destination() {};
	willThrow(DestinationResolutionException.class).given(this.jmsTemplate).send(eq(destination), any());

	this.thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
	this.messagingTemplate.send(destination, createTextMessage());
}
 
Example #6
Source File: JmsMessagingTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void convertDestinationResolutionExceptionOnReceive() {
	Destination destination = new Destination() {};
	willThrow(DestinationResolutionException.class).given(this.jmsTemplate).receive(destination);

	this.thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
	this.messagingTemplate.receive(destination);
}
 
Example #7
Source File: JmsMessagingTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void convertInvalidDestinationExceptionOnSendAndReceiveWithName() {
	willThrow(InvalidDestinationException.class).given(this.jmsTemplate).sendAndReceive(eq("unknownQueue"), any());

	this.thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
	this.messagingTemplate.sendAndReceive("unknownQueue", createTextMessage());
}
 
Example #8
Source File: JmsMessagingTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void convertInvalidDestinationExceptionOnSendAndReceive() {
	Destination destination = new Destination() {};
	willThrow(InvalidDestinationException.class).given(this.jmsTemplate).sendAndReceive(eq(destination), any());

	this.thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
	this.messagingTemplate.sendAndReceive(destination, createTextMessage());
}
 
Example #9
Source File: StandardJmsActivationSpecFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Populate the given ApplicationSpec object with the settings
 * defined in the given configuration object.
 * <p>This implementation applies all standard JMS settings, but ignores
 * "maxConcurrency" and "prefetchSize" - not supported in standard JCA 1.5.
 * @param bw the BeanWrapper wrapping the ActivationSpec object
 * @param config the configured object holding common JMS settings
 */
protected void populateActivationSpecProperties(BeanWrapper bw, JmsActivationSpecConfig config) {
	String destinationName = config.getDestinationName();
	boolean pubSubDomain = config.isPubSubDomain();
	Object destination = destinationName;
	if (this.destinationResolver != null) {
		try {
			destination = this.destinationResolver.resolveDestinationName(null, destinationName, pubSubDomain);
		}
		catch (JMSException ex) {
			throw new DestinationResolutionException("Cannot resolve destination name [" + destinationName + "]", ex);
		}
	}
	bw.setPropertyValue("destination", destination);
	bw.setPropertyValue("destinationType", pubSubDomain ? Topic.class.getName() : Queue.class.getName());

	if (bw.isWritableProperty("subscriptionDurability")) {
		bw.setPropertyValue("subscriptionDurability", config.isSubscriptionDurable() ? "Durable" : "NonDurable");
	}
	else if (config.isSubscriptionDurable()) {
		// Standard JCA 1.5 "subscriptionDurability" apparently not supported...
		throw new IllegalArgumentException(
				"Durable subscriptions not supported by underlying provider: " + this.activationSpecClass.getName());
	}
	if (config.isSubscriptionShared()) {
		throw new IllegalArgumentException("Shared subscriptions not supported for JCA-driven endpoints");
	}

	if (config.getSubscriptionName() != null) {
		bw.setPropertyValue("subscriptionName", config.getSubscriptionName());
	}
	if (config.getClientId() != null) {
		bw.setPropertyValue("clientId", config.getClientId());
	}
	if (config.getMessageSelector() != null) {
		bw.setPropertyValue("messageSelector", config.getMessageSelector());
	}
	applyAcknowledgeMode(bw, config.getAcknowledgeMode());
}
 
Example #10
Source File: JmsMessagingTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void convertDestinationResolutionExceptionOnSend() {
	Destination destination = new Destination() {};
	willThrow(DestinationResolutionException.class).given(jmsTemplate).send(eq(destination), anyObject());

	thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
	messagingTemplate.send(destination, createTextMessage());
}
 
Example #11
Source File: JmsMessagingTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void convertDestinationResolutionExceptionOnReceive() {
	Destination destination = new Destination() {};
	willThrow(DestinationResolutionException.class).given(jmsTemplate).receive(destination);

	thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
	messagingTemplate.receive(destination);
}
 
Example #12
Source File: JmsMessagingTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void convertInvalidDestinationExceptionOnSendAndReceiveWithName() {
	willThrow(InvalidDestinationException.class).given(jmsTemplate).sendAndReceive(eq("unknownQueue"), anyObject());

	thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
	messagingTemplate.sendAndReceive("unknownQueue", createTextMessage());
}
 
Example #13
Source File: JmsMessagingTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void convertInvalidDestinationExceptionOnSendAndReceive() {
	Destination destination = new Destination() {};
	willThrow(InvalidDestinationException.class).given(jmsTemplate).sendAndReceive(eq(destination), anyObject());

	thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
	messagingTemplate.sendAndReceive(destination, createTextMessage());
}
 
Example #14
Source File: StandardJmsActivationSpecFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Populate the given ApplicationSpec object with the settings
 * defined in the given configuration object.
 * <p>This implementation applies all standard JMS settings, but ignores
 * "maxConcurrency" and "prefetchSize" - not supported in standard JCA 1.5.
 * @param bw the BeanWrapper wrapping the ActivationSpec object
 * @param config the configured object holding common JMS settings
 */
protected void populateActivationSpecProperties(BeanWrapper bw, JmsActivationSpecConfig config) {
	String destinationName = config.getDestinationName();
	if (destinationName != null) {
		boolean pubSubDomain = config.isPubSubDomain();
		Object destination = destinationName;
		if (this.destinationResolver != null) {
			try {
				destination = this.destinationResolver.resolveDestinationName(null, destinationName, pubSubDomain);
			}
			catch (JMSException ex) {
				throw new DestinationResolutionException(
						"Cannot resolve destination name [" + destinationName + "]", ex);
			}
		}
		bw.setPropertyValue("destination", destination);
		bw.setPropertyValue("destinationType", pubSubDomain ? Topic.class.getName() : Queue.class.getName());
	}

	if (bw.isWritableProperty("subscriptionDurability")) {
		bw.setPropertyValue("subscriptionDurability", config.isSubscriptionDurable() ? "Durable" : "NonDurable");
	}
	else if (config.isSubscriptionDurable()) {
		// Standard JCA 1.5 "subscriptionDurability" apparently not supported...
		throw new IllegalArgumentException("Durable subscriptions not supported by underlying provider");
	}
	if (config.isSubscriptionShared()) {
		throw new IllegalArgumentException("Shared subscriptions not supported for JCA-driven endpoints");
	}

	if (config.getSubscriptionName() != null) {
		bw.setPropertyValue("subscriptionName", config.getSubscriptionName());
	}
	if (config.getClientId() != null) {
		bw.setPropertyValue("clientId", config.getClientId());
	}
	if (config.getMessageSelector() != null) {
		bw.setPropertyValue("messageSelector", config.getMessageSelector());
	}
	applyAcknowledgeMode(bw, config.getAcknowledgeMode());
}
 
Example #15
Source File: StandardJmsActivationSpecFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Populate the given ApplicationSpec object with the settings
 * defined in the given configuration object.
 * <p>This implementation applies all standard JMS settings, but ignores
 * "maxConcurrency" and "prefetchSize" - not supported in standard JCA 1.5.
 * @param bw the BeanWrapper wrapping the ActivationSpec object
 * @param config the configured object holding common JMS settings
 */
protected void populateActivationSpecProperties(BeanWrapper bw, JmsActivationSpecConfig config) {
	String destinationName = config.getDestinationName();
	if (destinationName != null) {
		boolean pubSubDomain = config.isPubSubDomain();
		Object destination = destinationName;
		if (this.destinationResolver != null) {
			try {
				destination = this.destinationResolver.resolveDestinationName(null, destinationName, pubSubDomain);
			}
			catch (JMSException ex) {
				throw new DestinationResolutionException(
						"Cannot resolve destination name [" + destinationName + "]", ex);
			}
		}
		bw.setPropertyValue("destination", destination);
		bw.setPropertyValue("destinationType", pubSubDomain ? Topic.class.getName() : Queue.class.getName());
	}

	if (bw.isWritableProperty("subscriptionDurability")) {
		bw.setPropertyValue("subscriptionDurability", config.isSubscriptionDurable() ? "Durable" : "NonDurable");
	}
	else if (config.isSubscriptionDurable()) {
		// Standard JCA 1.5 "subscriptionDurability" apparently not supported...
		throw new IllegalArgumentException("Durable subscriptions not supported by underlying provider");
	}
	if (config.isSubscriptionShared()) {
		throw new IllegalArgumentException("Shared subscriptions not supported for JCA-driven endpoints");
	}

	if (config.getSubscriptionName() != null) {
		bw.setPropertyValue("subscriptionName", config.getSubscriptionName());
	}
	if (config.getClientId() != null) {
		bw.setPropertyValue("clientId", config.getClientId());
	}
	if (config.getMessageSelector() != null) {
		bw.setPropertyValue("messageSelector", config.getMessageSelector());
	}
	applyAcknowledgeMode(bw, config.getAcknowledgeMode());
}