/
context.xml
74 lines (56 loc) · 3.1 KB
/
context.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd"
default-autowire="byName">
<context:property-placeholder/>
<bean id="rabbitMqUrlRegex" class="java.util.regex.Pattern" factory-method="compile">
<constructor-arg value="amqp://(.*):(.*)@(.*):(.*)(/.*)"/>
</bean>
<bean id="rabbitMqUrlMatcher" factory-bean="rabbitMqUrlRegex" factory-method="matcher" init-method="find">
<constructor-arg value="${RABBITMQ_URL:amqp://guest:guest@localhost:5672/}"/>
</bean>
<bean id="rabbitMqUser" factory-bean="rabbitMqUrlMatcher" factory-method="group">
<constructor-arg value="1"/>
</bean>
<bean id="rabbitMqPassword" factory-bean="rabbitMqUrlMatcher" factory-method="group">
<constructor-arg value="2"/>
</bean>
<bean id="rabbitMqHost" factory-bean="rabbitMqUrlMatcher" factory-method="group">
<constructor-arg value="3"/>
</bean>
<bean id="rabbitMqPortString" factory-bean="rabbitMqUrlMatcher" factory-method="group">
<constructor-arg value="4"/>
</bean>
<bean id="rabbitMqPort" class="java.lang.Integer" factory-method="valueOf">
<constructor-arg ref="rabbitMqPortString"/>
</bean>
<bean id="rabbitMqVHost" factory-bean="rabbitMqUrlMatcher" factory-method="group">
<constructor-arg value="5"/>
</bean>
<bean id="cf" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<property name="host" ref="rabbitMqHost"/>
<property name="port" ref="rabbitMqPort"/>
<property name="username" ref="rabbitMqUser"/>
<property name="password" value="rabbitMqPassword"/>
<property name="virtualHost" value="rabbitMqVHost"/>
</bean>
<rabbit:admin id="admin" connection-factory="cf"/>
<rabbit:queue id="silly-wabbit-queue" durable="true" auto-delete="false" exclusive="false"
name="silly-wabbit-queue"/>
<rabbit:direct-exchange name="silly-wabbit-exchange" durable="true" auto-delete="false" id="silly-wabbit-exchange">
<rabbit:bindings>
<rabbit:binding queue="silly-wabbit-queue" key="silly-wabbit-key"/>
</rabbit:bindings>
</rabbit:direct-exchange>
<bean id="template" class="org.springframework.amqp.rabbit.core.RabbitTemplate">
<property name="connectionFactory" ref="cf"/>
<property name="exchange" value="silly-wabbit-exchange"/>
<property name="queue" value="silly-wabbit-queue"/>
<property name="routingKey" value="silly-wabbit-key"/>
</bean>
</beans>