INTSAMPLES-132 AMQP Publisher Confirms/Returns

JIRA: https://jira.spring.io/browse/INTSAMPLES-132

Polishing - PR Comments
This commit is contained in:
Gary Russell
2014-08-07 11:02:27 +03:00
committed by Artem Bilan
parent 90d5ee9282
commit 28116776c2
8 changed files with 229 additions and 17 deletions

View File

@@ -11,13 +11,51 @@ Once the application is started, you enter some text on the command prompt and a
# How to Run the Sample
If you imported the example into your IDE, you can just run class **org.springframework.integration.samples.amqp.Main**. For example in [SpringSource Tool Suite](http://www.springsource.com/developer/sts) (STS) do:
If you imported the example into your IDE, you can just run class **org.springframework.integration.samples.amqp.SampleSimple**. For example in [SpringSource Tool Suite](http://www.springsource.com/developer/sts) (STS) do:
* Right-click on Main class --> Run As --> Java Application
* Right-click on SampleSimple class --> Run As --> Java Application
Alternatively, you can start the sample from the command line ([Gradle](http://www.gradle.org) required):
Alternatively, you can start the sample from the command line:
* gradlew :amqp:run
* ./gradlew :amqp:runSimple
Enter some data (e.g. 'foo') on the console; you will see a [tapInbound] log and 'Received: foo'.
Ctrl-C to terminate.
The __SamplePubConfirmsReturns__ class is similar, but demonstrates publisher confirms and returns.
* Right-click on SamplePubConfirmsReturns class --> Run As --> Java Application
Or:
* ./gradlew :amqp:runPubConfirmsReturns
When you enter a message in the console you will see the message received, together with a send confirmation:
````
foo
Received: foo
foo sent ok
````
When you enter 'fail', the message is sent with a bad routing key; you will see the message is sent ok, but returned because it is not routable:
````
fail
fail returned:NO_ROUTE
fail sent ok
````
When you enter 'nack', the message is sent to a non-existent exchange; the broker reacts to this by closing the channel with an error and Spring AMQP generates a Nack:
````
nack
nack send failed (nack)
11:54:00.818 ERROR [pool-1-thread-1][org.springframework.amqp.rabbit.connection.CachingConnectionFactory] Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'badExchange' in vhost '/', class-id=60, method-id=40)
````
Ctrl-C to terminate.
# Used Spring Integration components