Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
2fea6064
Commit
2fea6064
authored
Sep 06, 2018
by
songxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RabbitMQ配置文件相关
parent
2f7df8de
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
168 additions
and
0 deletions
+168
-0
MQQueueConstant.java
...java/com/pcloud/common/core/constant/MQQueueConstant.java
+48
-0
MQTopicProducer.java
...java/com/pcloud/common/core/constant/MQTopicProducer.java
+29
-0
ActiveMqProducer.java
...main/java/com/pcloud/common/core/mq/ActiveMqProducer.java
+0
-0
RabbitMQFactory.java
.../main/java/com/pcloud/common/core/mq/RabbitMQFactory.java
+91
-0
No files found.
pcloud-common-core/src/main/java/com/pcloud/common/core/constant/MQQueueConstant.java
0 → 100644
View file @
2fea6064
/**
*
*/
package
com
.
pcloud
.
common
.
core
.
constant
;
/**
*
* @author:songx
* @date:2018年8月16日,下午9:54:51
*/
public
class
MQQueueConstant
{
/**
* 模板消息
*/
public
static
final
String
TEMPLATE
=
"templateQueue"
;
/**
* 文件转码(PDF、OFFICE)
*/
public
static
final
String
TRANSCODE
=
"transcodeQueue"
;
/**
* 文件转码(音视频)
*/
public
static
final
String
CONVERT
=
"convertQueue"
;
/**
* 文件转码结束(音视频)->应用中心
*/
public
static
final
String
CONVERT_TO_APP
=
"convert2AppQueue"
;
/**
* 文件转码结束(音视频)->内容中心
*/
public
static
final
String
CONVERT_TO_CONTENT
=
"convert2ContentQueue"
;
/**
* 数据埋点
*/
public
static
final
String
FRONT_EVENT_QUEUE
=
"frontEventQueue"
;
/**
* 死信队列名称(勿改)
*/
public
static
final
String
DEAD
=
"rays.dlq"
;
}
pcloud-common-core/src/main/java/com/pcloud/common/core/constant/MQTopicProducer.java
0 → 100644
View file @
2fea6064
/**
*
*/
package
com
.
pcloud
.
common
.
core
.
constant
;
/**
* RabbitMQ 交换机名称常量类
*
* @author:songx
* @date:2018年8月17日,上午10:48:18
*/
public
class
MQTopicProducer
{
/**
* 应用新增
*/
public
static
final
String
APP_ADD
=
"topic.appAdd"
;
/**
* 文件转码结束(PDF、EXCEL)
*/
public
static
final
String
FILE_TRANSCODE
=
"topic.fileTranscode"
;
/**
* topic交换机名称(勿改)
*/
public
static
final
String
EXCHAGE
=
"rays.topic"
;
}
pcloud-common-core/src/main/java/com/pcloud/common/core/mq/ActiveMqProducer.java
View file @
2fea6064
This diff is collapsed.
Click to expand it.
pcloud-common-core/src/main/java/com/pcloud/common/core/mq/RabbitMQFactory.java
0 → 100644
View file @
2fea6064
package
com
.
pcloud
.
common
.
core
.
mq
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.amqp.core.Binding
;
import
org.springframework.amqp.core.BindingBuilder
;
import
org.springframework.amqp.core.DirectExchange
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.amqp.core.QueueBuilder
;
import
org.springframework.amqp.core.TopicExchange
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.constant.MQTopicProducer
;
/**
* RabbitMQ
*
* @author:songx
* @date:2018年8月16日,上午11:22:49
*/
@Configuration
public
class
RabbitMQFactory
{
private
static
final
String
DEAD_LETTER_EXCHANGE
=
"rays.dlx"
;
private
static
final
String
DEAD_ROUTING_KEY
=
"rays.dlk"
;
private
static
TopicExchange
topicExchange
=
null
;
/**
* 声明业务队列同时与死信队列绑定,当业务队列的消息失败时会转发到死信队列中在进行处理,防止信息丢失
*
* @param queueName
* 队列名称
* @return
*/
public
static
Queue
queueBuilder
(
String
queueName
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"x-dead-letter-exchange"
,
DEAD_LETTER_EXCHANGE
);
// 设置死信交换机
map
.
put
(
"x-dead-letter-routing-key"
,
DEAD_ROUTING_KEY
);
// 设置死信routingKey
return
QueueBuilder
.
durable
(
queueName
).
withArguments
(
map
).
build
();
}
@Bean
public
Queue
deadQueue
()
{
return
new
Queue
(
MQQueueConstant
.
DEAD
);
}
@Bean
public
DirectExchange
deadLetterExchange
()
{
return
new
DirectExchange
(
DEAD_LETTER_EXCHANGE
,
true
,
false
);
}
@Bean
public
Binding
deadBinding
()
{
return
BindingBuilder
.
bind
(
deadQueue
()).
to
(
deadLetterExchange
()).
with
(
DEAD_ROUTING_KEY
);
}
/**
* Topic模式下生产者与消费者到交换机的绑定
*
* @param queue
* 消费者队列
* @param producer
* 生产者名称
* @return
*/
public
static
Binding
bindingExchange
(
Queue
queue
,
String
producer
)
{
return
BindingBuilder
.
bind
(
queue
).
to
(
getTopicExchange
()).
with
(
producer
);
}
@Bean
TopicExchange
topicExchange
()
{
return
getTopicExchange
();
}
/**
*
* @return
*/
private
static
TopicExchange
getTopicExchange
()
{
if
(
topicExchange
==
null
)
{
topicExchange
=
new
TopicExchange
(
MQTopicProducer
.
EXCHAGE
);
}
return
topicExchange
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment