Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. <beans xmlns="http://www.springframework.org/schema/beans"
  2. xmlns:int="http://www.springframework.org/schema/integration"
  3. xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
  4. xmlns:rabbit="http://www.springframework.org/schema/rabbit"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xmlns:context="http://www.springframework.org/schema/context"
  7.  
  8. xsi:schemaLocation="http://www.springframework.org/schema/beans
  9. http://www.springframework.org/schema/beans/spring-beans.xsd
  10. http://www.springframework.org/schema/integration
  11. http://www.springframework.org/schema/integration/spring-integration.xsd
  12. http://www.springframework.org/schema/integration/amqp
  13. http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd
  14. http://www.springframework.org/schema/rabbit
  15. http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
  16. http://www.springframework.org/schema/context
  17. http://www.springframework.org/schema/context/spring-context.xsd">
  18.  
  19. <rabbit:connection-factory id="connectionFactory" host="bigdata-rdp" username="myuser" password="mypass" />
  20. <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" />
  21. <rabbit:admin connection-factory="connectionFactory" />
  22. <rabbit:queue name="first" auto-delete="false" durable="true" />
  23. <rabbit:queue name="second" auto-delete="false" durable="true" />
  24. <rabbit:queue name="errorQueue" auto-delete="false" durable="true" />
  25.  
  26. <rabbit:fanout-exchange name="second-exchange" auto-delete="true" durable="true">
  27. <rabbit:bindings>
  28. <rabbit:binding queue="second" />
  29. </rabbit:bindings>
  30. </rabbit:fanout-exchange>
  31.  
  32. <rabbit:fanout-exchange name="error-exchange" auto-delete="true" durable="true">
  33. <rabbit:bindings>
  34. <rabbit:binding queue="errorQueue" />
  35. </rabbit:bindings>
  36. </rabbit:fanout-exchange>
  37.  
  38. <int-amqp:outbound-channel-adapter channel="messageOutputChannel" exchange-name="second-exchange" amqp-template="amqpTemplate" />
  39.  
  40. <int-amqp:inbound-channel-adapter channel="messageInputChannel" error-channel = "errorInputChannel" queue-names="first" connection-factory="connectionFactory" concurrent-consumers="20" />
  41.  
  42. <int-amqp:outbound-channel-adapter channel="errorOutputChannel" exchange-name="error-exchange" amqp-template="amqpTemplate" />
  43.  
  44. <bean id="MessageErrorHandler" class = "firstAttempt.MessageErrorHandler"/>
  45. <int:channel id="messageInputChannel" />
  46. <int:channel id="messageOutputChannel"/>
  47. <int:channel id="errorOutputChannel"/>
  48. <int:channel id="errorInputChannel"/>
  49.  
  50. <int:chain input-channel="errorInputChannel" output-channel="errorOutputChannel">
  51. <int:header-enricher >
  52. <int:header name="error" expression = "getPayload()"/>
  53. </int:header-enricher>
  54. <int:service-activator method = "handleError" >
  55. <bean class="firstAttempt.MessageErrorHandler"/>
  56. </int:service-activator>
  57. </int:chain>
  58.  
  59.  
  60. <int:chain input-channel="messageInputChannel" output-channel="messageOutputChannel">
  61. <int:transformer method = "convert" >
  62. <bean class="firstAttempt.JsonObjectConverter" />
  63. </int:transformer>
  64. <int:service-activator method="transform">
  65. <bean class="firstAttempt.Transformer" />
  66. </int:service-activator>
  67. <int:object-to-string-transformer />
  68. </int:chain>
  69.  
  70. </beans>
  71.  
  72. public class MessageErrorHandler {
  73. public String handleError(MessageHandlingException m) {
  74. return m.getMessage();
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement