Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit fb990d8

Browse files
authored
fix: Remove hard-coded /user prefix for broker queues (#56)
Signed-off-by: Josh Kim <[email protected]>
1 parent a49ff42 commit fb990d8

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

src/bridge/broker-connector.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export class BrokerConnector implements EventBusEnabled {
315315
const subscriptionId = this.generateSubscriptionId(session.id, cleanedChannel);
316316
const brokerPrefix = galacticConfig.isPrivate ? config.queueLocation : config.topicLocation;
317317
const destination =
318-
StompParser.generateGalacticDesintation(brokerPrefix, cleanedChannel, galacticConfig.isPrivate);
318+
StompParser.generateGalacticDesintation(brokerPrefix, cleanedChannel);
319319
const subscription =
320320
StompParser.generateStompBrokerSubscriptionRequest(
321321
session.id, destination, subscriptionId, galacticConfig.isPrivate, brokerPrefix
@@ -358,7 +358,7 @@ export class BrokerConnector implements EventBusEnabled {
358358
const brokerPrefix = this._privateChannels.get(channel)[sessionBrokerIdentity] ?
359359
config.queueLocation : config.topicLocation;
360360
const destination =
361-
StompParser.generateGalacticDesintation(brokerPrefix, cleanedChannel, isPrivateChannel);
361+
StompParser.generateGalacticDesintation(brokerPrefix, cleanedChannel);
362362
const subscription = StompParser.generateStompBrokerSubscriptionRequest(
363363
session.id, destination, subscriptionId, isPrivateChannel, brokerPrefix);
364364

@@ -741,7 +741,7 @@ export class BrokerConnector implements EventBusEnabled {
741741
);
742742

743743
const channel: string = StompParser.convertTopicOrQueueToChannel(
744-
data.destination, data.brokerPrefix, data.isQueue);
744+
data.destination, data.brokerPrefix);
745745

746746
const chan: Observable<Message> =
747747
this.bus.api.getRequestChannel(channel, this.getName());
@@ -764,8 +764,7 @@ export class BrokerConnector implements EventBusEnabled {
764764
let respChan =
765765
StompParser.convertSubscriptionToChannel(
766766
data.destination,
767-
data.isQueue ? session.config.queueLocation : session.config.topicLocation,
768-
data.isQueue);
767+
data.isQueue ? session.config.queueLocation : session.config.topicLocation);
769768
let payload = JSON.parse(msg.body);
770769

771770
const respChannelObject = this.bus.api.getChannelObject(respChan);
@@ -820,8 +819,7 @@ export class BrokerConnector implements EventBusEnabled {
820819

821820
// let the bus know.
822821
this.sendBusCommandResponseRaw(message, BrokerConnectorChannel.subscription, true);
823-
const channel: string = StompParser.convertTopicOrQueueToChannel(
824-
data.destination, data.brokerPrefix, data.isQueue);
822+
const channel: string = StompParser.convertTopicOrQueueToChannel(data.destination, data.brokerPrefix);
825823

826824
const sub: Subscription = session.getGalacticSubscription(channel);
827825

src/bridge/stomp.parser.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,12 @@ describe('Stomp Parser [stomp.parser]', () => {
248248

249249
// public channel
250250
const subA = StompParser.convertSubscriptionToChannel(
251-
'puppykitty/', 'kitty', false);
251+
'puppykitty/', 'kitty');
252252
expect(subA).toEqual('puppy');
253253

254254
// private channel
255255
const subB = StompParser.convertSubscriptionToChannel(
256-
'/userpuppy/kitty', 'puppy', true);
256+
'puppy/kitty', 'puppy');
257257
expect(subB).toEqual('kitty');
258258

259259
}

src/bridge/stomp.parser.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,22 @@ export class StompParser {
202202
}
203203

204204
// create galactic topic/queue detination
205-
public static generateGalacticDesintation(dest: string, channel: string, isQueue: boolean): string {
206-
return (isQueue ? '/user' : '') + dest + '/' + channel;
205+
public static generateGalacticDesintation(dest: string, channel: string): string {
206+
return dest + '/' + channel;
207207
}
208208

209209
// convert destination back into a channel
210210
public static convertSubscriptionToChannel(subscription: string,
211-
topicOrQueueDesintation: string,
212-
isQueue: boolean): string {
211+
topicOrQueueDesintation: string): string {
213212
return subscription.replace(
214-
(isQueue ? '/user' + topicOrQueueDesintation : topicOrQueueDesintation) + '/',
213+
topicOrQueueDesintation + '/',
215214
'');
216215
}
217216

218217
// convert topic/queue back into a channel
219218
public static convertTopicOrQueueToChannel(subscription: string,
220-
brokerPrefix: string,
221-
isQueue: boolean): string {
219+
brokerPrefix: string): string {
222220
return subscription.replace(
223-
isQueue ? '/user' + brokerPrefix + '/' : brokerPrefix + '/', '').trim();
221+
brokerPrefix + '/', '').trim();
224222
}
225223
}

0 commit comments

Comments
 (0)