File tree Expand file tree Collapse file tree 4 files changed +26
-7
lines changed Expand file tree Collapse file tree 4 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 1- [rabbitmq_stream_management,rabbitmq_consistent_hash_exchange].
1+ [rabbit_stream, rabbitmq_stream_management,rabbitmq_consistent_hash_exchange].
Original file line number Diff line number Diff line change @@ -81,16 +81,12 @@ export class AmqpConsumer implements Consumer {
8181
8282 start ( ) {
8383 this . receiverLink . on ( ReceiverEvents . message , ( context : EventContext ) => {
84- console . log ( "message received" , context . message ?. body )
8584 if ( context . message && context . delivery ) {
86- console . log ( "message accepted" )
8785 try {
8886 this . params . messageHandler ( context . message )
8987 context . delivery . accept ( )
90- console . log ( "message consumed" )
9188 } catch ( e ) {
9289 context . delivery . reject ( { condition : "Message Handler error" , info : e } )
93- console . log ( "message rejected" )
9490 }
9591 }
9692 } )
Original file line number Diff line number Diff line change 1- import { generate_uuid , Message as RheaMessage } from "rhea"
1+ import { generate_uuid , MessageAnnotations , Message as RheaMessage } from "rhea"
22import { AmqpEndpoints } from "./link_message_builder.js"
33import { inspect } from "util"
44
@@ -16,6 +16,7 @@ export type DestinationOptions = { exchange: ExchangeOptions } | { queue: QueueO
1616type MessageOptions = {
1717 body : string
1818 destination ?: DestinationOptions
19+ annotations ?: MessageAnnotations
1920}
2021
2122export function createAmqpMessage ( options : MessageOptions ) : RheaMessage {
@@ -25,10 +26,16 @@ export function createAmqpMessage(options: MessageOptions): RheaMessage {
2526 body : options . body ,
2627 to : createAddressFrom ( options . destination ) ,
2728 durable : true ,
29+ message_annotations : options . annotations ?? { } ,
2830 }
2931 }
3032
31- return { message_id : generate_uuid ( ) , body : options . body , durable : true }
33+ return {
34+ message_id : generate_uuid ( ) ,
35+ body : options . body ,
36+ durable : true ,
37+ message_annotations : options . annotations ?? { } ,
38+ }
3239}
3340
3441export function createAddressFrom ( options ?: DestinationOptions ) : string | undefined {
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ describe("Publisher", () => {
2424 const queueName2 = "test-queue-2"
2525 const bindingKey = "test-key"
2626 const bindingKey2 = "test-key-2"
27+ const streamName = "test-stream"
2728
2829 beforeEach ( async ( ) => {
2930 environment = createEnvironment ( {
@@ -117,4 +118,19 @@ describe("Publisher", () => {
117118
118119 expect ( publishResult . outcome ) . to . eql ( OutcomeState . RELEASED )
119120 } )
121+
122+ test ( "publish a message to a stream" , async ( ) => {
123+ const management = connection . management ( )
124+ await management . declareQueue ( streamName , { type : "stream" } )
125+ const publisher = await connection . createPublisher ( { queue : { name : streamName } } )
126+
127+ const publishResult = await publisher . publish (
128+ createAmqpMessage ( {
129+ body : "Hello World!" ,
130+ annotations : { "x-stream-filter-value" : "invoices" } ,
131+ } )
132+ )
133+
134+ expect ( publishResult . outcome ) . to . eql ( OutcomeState . ACCEPTED )
135+ } )
120136} )
You can’t perform that action at this time.
0 commit comments