Skip to content

Commit

Permalink
Merge pull request #61 from aashikam/docs
Browse files Browse the repository at this point in the history
Update docs for Ballerina Swan Lake Preview 1
  • Loading branch information
aashikam committed Jun 30, 2020
2 parents 5588dc2 + 2601885 commit d475437
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- run: mvn clean install -pl !java.jms
- run: cd java.jms
- name: Ballerina Build
uses: ballerina-platform/ballerina-action/@master
uses: ballerina-platform/ballerina-action/@swan-lake-release
with:
args:
build -a -c --sourceroot java.jms
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- run: mvn clean install -pl !java.jms
- run: cd java.jms
- name: Ballerina Build
uses: ballerina-platform/ballerina-action/@master
uses: ballerina-platform/ballerina-action/@swan-lake-release
with:
args:
build -a -c --sourceroot java.jms
Expand Down
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/wso2-ballerina/module-jms.svg?branch=master)](https://travis-ci.org/wso2-ballerina/module-jms)
[![Build Status](https://travis-ci.com/ballerina-platform/module-ballerina-java.jms.svg?branch=master)](https://travis-ci.com/ballerina-platform/module-ballerina-java.jms)

## Module overview

Expand Down Expand Up @@ -28,6 +28,7 @@ The following sections provide details on how to use the JMS connector.
| 1.0.x | 0.6.x |
| 1.1.x | 0.7.x |
| 1.2.x | 0.8.x |
| Swan Lake Preview1 | 0.99.x |

## Samples

Expand Down Expand Up @@ -82,10 +83,8 @@ jms:Connection connection = check jms:createConnection({
initialContextFactory: "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
jms:Session session = check connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination topic = check session->createTopic("MyTopic");
listener jms:MessageConsumer jmsConsumer = check session->createDurableSubscriber(topic, "sub-1");
listener jms:MessageConsumer jmsConsumer = createListener(connection);
service messageListener on jmsConsumer {
Expand All @@ -102,4 +101,38 @@ service messageListener on jmsConsumer {
}
}
}
function createListener(jms:Connection connection) returns jms:MessageConsumer {
jms:Session session = checkpanic connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination queue = checkpanic session->createQueue("MyQueue");
jms:MessageConsumer consumer = checkpanic session->createConsumer(queue);
return consumer;
}
```
## Adding the required dependencies

Add the required dependencies to the `Ballerina.toml` file based on the broker that you're trying to connect to.
Add the configurations below to run the given examples using `Apache ActiveMQ`.

```
[[platform.libraries]]
module = "jms"
path = "<path>/activemq-client-5.15.12.jar"
artifactId = "activemq-client"
version = "5.15.12"
groupId = "org.apache.activemq"
[[platform.libraries]]
module = "jms"
path = "<path>/geronimo-j2ee-management_1.1_spec-1.0.1.jar"
artifactId = "geronimo-j2ee-management_1.1_spec"
version = "1.0.1"
groupId = "org.apache.geronimo.specs"
[[platform.libraries]]
module = "jms"
path = "<path>/libs/hawtbuf-1.11.jar"
artifactId = "hawtbuf"
version = "1.11"
groupId = "org.fusesource.hawtbuf"
```
4 changes: 2 additions & 2 deletions compiler-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
<parent>
<groupId>org.ballerinalang</groupId>
<artifactId>module-jms</artifactId>
<version>0.9.0</version>
<version>0.99.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jms-compiler-plugin</artifactId>
<version>0.9.0</version>
<version>0.99.0</version>
<packaging>jar</packaging>
<name>JMS Compiler Plugin</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ jms:Connection connection = check jms:createConnection({
initialContextFactory: "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
jms:Session session = check connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination topic = check session->createTopic("MyTopic");

listener jms:MessageConsumer jmsConsumer = check session->createDurableSubscriber(topic, "sub-1");
listener jms:MessageConsumer jmsConsumer = createListener(connection);

service messageListener on jmsConsumer {

Expand All @@ -25,3 +23,10 @@ service messageListener on jmsConsumer {
}
}
}

function createListener(jms:Connection connection) returns jms:MessageConsumer {
jms:Session session = checkpanic connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination topic = checkpanic session->createTopic("MyTopic");
jms:MessageConsumer jmsConsumer = check session->createDurableSubscriber(topic, "sub-1");
return jmsConsumer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ jms:Connection connection = check jms:createConnection({
initialContextFactory: "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
jms:Session session = check connection->createSession({acknowledgementMode: "CLIENT_ACKNOWLEDGE"});
jms:Destination queue = check session->createQueue("MyQueue");

listener jms:MessageConsumer jmsConsumer = check session->createConsumer(queue);
listener jms:MessageConsumer jmsConsumer = createListener(connection);

service messageListener on jmsConsumer {

Expand All @@ -29,3 +27,10 @@ service messageListener on jmsConsumer {
}
}
}

function createListener(jms:Connection connection) returns jms:MessageConsumer {
jms:Session session = check connection->createSession({acknowledgementMode: "CLIENT_ACKNOWLEDGE"});
jms:Destination queue = check session->createQueue("MyQueue");
jms:MessageConsumer jmsConsumer = checkpanic session->createConsumer(queue);
return jmsConsumer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ jms:Connection connection = check jms:createConnection({
initialContextFactory: "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
jms:Session session = check connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination topic = check session->createTopic("MyTopic");

listener jms:MessageConsumer jmsConsumer = check session->createConsumer(topic);
listener jms:MessageConsumer jmsConsumer = createListener(connection);

service messageListener on jmsConsumer {

Expand All @@ -25,3 +23,10 @@ service messageListener on jmsConsumer {
}
}
}

function createListener(jms:Connection connection) returns jms:MessageConsumer {
jms:Session session = checkpanic connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination topic = checkpanic session->createTopic("MyTopic");
jms:MessageConsumer jmsConsumer = checkpanic session->createConsumer(topic);
return jmsConsumer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ jms:Connection connection = check jms:createConnection({
initialContextFactory: "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
jms:Session session = check connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination queue = check session->createQueue("MyQueue");

listener jms:MessageConsumer jmsConsumer = check session->createConsumer(queue);
listener jms:MessageConsumer jmsConsumer = createListener(connection);

service messageListener on jmsConsumer {

Expand Down Expand Up @@ -81,3 +79,10 @@ service backend on new http:Listener(9090) {
}
}
}

function createListener(jms:Connection connection) returns jms:MessageConsumer {
jms:Session session = checkpanic connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination queue = checkpanic session->createQueue("MyQueue");
jms:MessageConsumer jmsConsumer = checkpanic session->createConsumer(queue);
return jmsConsumer;
}
10 changes: 5 additions & 5 deletions java.jms/Ballerina.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
org_name = "ballerina"
version = "0.9.0"
version = "0.99.0"
lockfile_version = "1.0.0"
ballerina_version = "slp1"

Expand All @@ -13,22 +13,22 @@ org_name = "ballerina"
name = "java"
version = "0.9.0"

[[imports."ballerina/java.jms:0.9.0"]]
[[imports."ballerina/java.jms:0.99.0"]]
org_name = "ballerina"
name = "observe"
version = "0.8.0"

[[imports."ballerina/java.jms:0.9.0"]]
[[imports."ballerina/java.jms:0.99.0"]]
org_name = "ballerina"
name = "log"
version = "1.0.0"

[[imports."ballerina/java.jms:0.9.0"]]
[[imports."ballerina/java.jms:0.99.0"]]
org_name = "ballerina"
name = "java"
version = "0.9.0"

[[imports."ballerina/java.jms:0.9.0"]]
[[imports."ballerina/java.jms:0.99.0"]]
org_name = "ballerina"
name = "lang.object"
version = "1.0.0"
6 changes: 3 additions & 3 deletions java.jms/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
org-name= "ballerina"
version= "0.9.0"
version= "0.99.0"
license= ["Apache-2.0"]
authors = ["Ballerina"]
keywords = ["jms"]
Expand All @@ -13,9 +13,9 @@ target = "java8"

[[platform.libraries]]
module = "java.jms"
path = "../utils/target/jms-utils-0.9.0.jar"
path = "../utils/target/jms-utils-0.99.0.jar"
artifactId = "jms-utils"
version = "0.9.0"
version = "0.99.0"
groupId = "org.ballerinalang"

[[platform.libraries]]
Expand Down
2 changes: 1 addition & 1 deletion java.jms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.ballerinalang</groupId>
<artifactId>module-jms</artifactId>
<version>0.9.0</version>
<version>0.99.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
42 changes: 38 additions & 4 deletions java.jms/src/java.jms/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Currently, the following JMS API Classes are supported through this module.
| 1.0.x | 0.6.x |
| 1.1.x | 0.7.x |
| 1.2.x | 0.8.x |
| Swan Lake Preview1 | 0.99.x |

## Samples

Expand Down Expand Up @@ -82,11 +83,9 @@ jms:Connection connection = check jms:createConnection({
initialContextFactory: "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
jms:Session session = check connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination topic = check session->createTopic("MyTopic");
`listener jms:MessageConsumer jmsConsumer = check session->createDurableSubscriber(topic, "sub-1");
`
listener jms:MessageConsumer jmsConsumer = createListener(connection);
service messageListener on jmsConsumer {
resource function onMessage(jms:Message message) {
Expand All @@ -102,4 +101,39 @@ service messageListener on jmsConsumer {
}
}
}
function createListener(jms:Connection connection) returns jms:MessageConsumer {
jms:Session session = checkpanic connection->createSession({acknowledgementMode: "AUTO_ACKNOWLEDGE"});
jms:Destination queue = checkpanic session->createQueue("MyQueue");
jms:MessageConsumer consumer = checkpanic session->createConsumer(queue);
return consumer;
}
```

## Adding the required dependencies

Add the required dependencies to the `Ballerina.toml` file based on the broker that you're trying to connect to.
Add the configurations below to run the given examples using `Apache ActiveMQ`.

```
[[platform.libraries]]
module = "jms"
path = "<path>/activemq-client-5.15.12.jar"
artifactId = "activemq-client"
version = "5.15.12"
groupId = "org.apache.activemq"
[[platform.libraries]]
module = "jms"
path = "<path>/geronimo-j2ee-management_1.1_spec-1.0.1.jar"
artifactId = "geronimo-j2ee-management_1.1_spec"
version = "1.0.1"
groupId = "org.apache.geronimo.specs"
[[platform.libraries]]
module = "jms"
path = "<path>/libs/hawtbuf-1.11.jar"
artifactId = "hawtbuf"
version = "1.11"
groupId = "org.fusesource.hawtbuf"
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<groupId>org.ballerinalang</groupId>
<artifactId>module-jms</artifactId>
<packaging>pom</packaging>
<version>0.9.0</version>
<version>0.99.0</version>
<name>Ballerina JMS Module</name>

<modules>
Expand Down
4 changes: 2 additions & 2 deletions utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
<parent>
<artifactId>module-jms</artifactId>
<groupId>org.ballerinalang</groupId>
<version>0.9.0</version>
<version>0.99.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>0.9.0</version>
<version>0.99.0</version>
<artifactId>jms-utils</artifactId>
<packaging>jar</packaging>
<name>JMS Utils</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Constants {

static final String ORG = "ballerina";
static final String PACKAGE_NAME = "java.jms";
public static final String VERSION = "0.9.0";
public static final String VERSION = "0.99.0";

// Destination types
public static final String DESTINATION_TYPE_QUEUE = "queue";
Expand Down

0 comments on commit d475437

Please sign in to comment.