Skip to content

Commit 444891d

Browse files
committed
Refactor code base
1 parent 97da1e9 commit 444891d

File tree

4 files changed

+38
-25
lines changed

4 files changed

+38
-25
lines changed

examples/ez-food/order-processor/Ballerina.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ filePath = "persist/model.bal"
2222
groupId = "io.ballerina.stdlib"
2323
artifactId = "persist.inmemory-native"
2424
version = "1.6.0"
25-
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2025, WSO2 LLC. (http://www.wso2.org).
2+
//
3+
// WSO2 LLC. licenses this file to you under the Apache License,
4+
// Version 2.0 (the "License"); you may not use this file except
5+
// in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing,
11+
// software distributed under the License is distributed on an
12+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
// KIND, either express or implied. See the License for the
14+
// specific language governing permissions and limitations
15+
// under the License.
16+
17+
import ballerinax/java.jms;
18+
19+
const string ORDERS_QUEUE = "orders";
20+
const string ORDER_CONFIRMATIONS_QUEUE = "order-confirmation";
21+
const string ORDER_STATUS_UPDATE_TOPIC = "order-status-update";
22+
23+
configurable jms:ConnectionConfiguration activeMqConnectionConfig = {
24+
initialContextFactory: "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
25+
providerUrl: "tcp://localhost:61616"
26+
};
27+
28+
final jms:MessageProducer producer = check createProducer();
29+
30+
isolated function createProducer() returns jms:MessageProducer|error {
31+
jms:Connection connection = check new (activeMqConnectionConfig);
32+
jms:Session session = check connection->createSession();
33+
return session.createProducer();
34+
}
35+
36+
listener jms:Listener activeMqListener = check new (activeMqConnectionConfig);

examples/ez-food/order-processor/order_details_listener.bal

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,10 @@ import orderprocessor.store;
1717

1818
import ballerinax/java.jms;
1919

20-
const string ORDERS_QUEUE = "orders";
21-
const string ORDER_CONFIRMATIONS_QUEUE = "order-confirmation";
22-
23-
configurable jms:ConnectionConfiguration activeMqConnectionConfig = {
24-
initialContextFactory: "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
25-
providerUrl: "tcp://localhost:61616"
26-
};
27-
28-
final jms:MessageProducer producer = check createProducer();
29-
30-
isolated function createProducer() returns jms:MessageProducer|error {
31-
jms:Connection connection = check new (activeMqConnectionConfig);
32-
jms:Session session = check connection->createSession();
33-
return session.createProducer();
34-
}
35-
36-
listener jms:Listener orderDetailsListener = check new (activeMqConnectionConfig);
37-
3820
@jms:ServiceConfig {
3921
queueName: ORDERS_QUEUE
4022
}
41-
service "order-details-receiver" on orderDetailsListener {
23+
service "order-details-receiver" on activeMqListener {
4224
remote function onMessage(jms:Message message) returns error? {
4325
if message !is jms:BytesMessage {
4426
return;

examples/ez-food/order-processor/order_status_listener.bal

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
// under the License.
1616
import ballerinax/java.jms;
1717

18-
const string ORDER_STATUS_UPDATE_TOPIC = "order-status-update";
19-
20-
listener jms:Listener orderStatusListener = check new (activeMqConnectionConfig);
21-
2218
@jms:ServiceConfig {
2319
topicName: ORDER_STATUS_UPDATE_TOPIC,
2420
subscriberName: "order-processor-consumer"
2521
}
26-
service "order-status-update-receiver" on orderStatusListener {
22+
service "order-status-update-receiver" on activeMqListener {
2723
remote function onMessage(jms:Message message) returns error? {
2824
if message !is jms:BytesMessage {
2925
return;

0 commit comments

Comments
 (0)