2020-06-17 10:27:36 +00:00
|
|
|
/// <reference types="@ccms/nashorn" />
|
2020-06-22 02:44:17 +00:00
|
|
|
/// <reference types="@javatypes/jdk" />
|
|
|
|
/// <reference types="@javatypes/spring-amqp" />
|
|
|
|
/// <reference types="@javatypes/spring-rabbit" />
|
|
|
|
/// <reference types="@javatypes/amqp-client" />
|
2020-06-17 10:27:36 +00:00
|
|
|
|
|
|
|
import { amqp } from '@ccms/api'
|
|
|
|
import { getContainer, reduceMetadata } from '@ccms/container'
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
const beanFactory = base.getInstance().getAutowireCapableBeanFactory()
|
|
|
|
getContainer().bind(amqp.rabbit.Template).toDynamicValue((ctx) => {
|
|
|
|
let metadata = reduceMetadata(ctx)
|
|
|
|
if (!metadata.named) {
|
|
|
|
return beanFactory.getBean('rabbitTemplate')
|
|
|
|
} else {
|
|
|
|
return beanFactory.getBean(`${metadata.named}-rabbitTemplate`)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
getContainer().bind(amqp.rabbit.Admin).toDynamicValue((ctx) => {
|
|
|
|
let metadata = reduceMetadata(ctx)
|
|
|
|
if (!metadata.named) {
|
|
|
|
return beanFactory.getBean('rabbitAdmin')
|
|
|
|
} else {
|
|
|
|
return beanFactory.getBean(`${metadata.named}-rabbitAdmin`)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
init()
|
|
|
|
|
|
|
|
export * from './admin'
|
|
|
|
export * from './adapter'
|
|
|
|
export * from './manager'
|
|
|
|
export * from './constants'
|