Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ links-pubsub-tutorial: http://dev.solace.com/get-started/java-tutorials/publish-
links-tls-client: http://docs.solace.com/Solace-Messaging-APIs/Creating-Secure-Sessions.htm
links-tls-server: https://docs.pivotal.io/solace-messaging/installing.html#configure
links-vcap: http://docs.pivotal.io/solace-messaging/credentials.html
links-configuring-connection: http://docs.solace.com/Solace-Messaging-APIs/Configuring-Connection-T.htm
links-best-practices: http://docs.solace.com/Solace-Messaging-APIs/Best-Practices.htm
#----------------------------------------------------
# Generally don't modify items below this point
url: "solacesamples.github.io" # the base hostname & protocol for your site
Expand Down
10 changes: 10 additions & 0 deletions docs/_includes/intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@ <h2 class="nolineheading">{{ site.title }}</h2>

<p>Solace Messaging is available in a number of network and deployment environments including Public/Private PaaS, Public/Private IaaS, LAN, WAN, Web, and Wireless ensuring your applications will have Solace Messaging available to them wherever they are deployed.</p>

<p>Solace Messaging supports High Availability configurations, where each message router is assigned a backup that takes over in case of failures. Details about how to use this are in the Java Application tutorial.
Be sure to read the
<a href="http://docs.solace.com/Solace-Messaging-APIs/Best-Practices.htm" target="_top">Best Practices</a>
and
<a href="http://docs.solace.com/Solace-Messaging-APIs/Configuring-Connection-T.htm" target="_top">Configuring Connection Time-Outs and Retries</a>
documents.
</p>

<p>Here are a few links you might find interesting if you are new to Solace Messaging in Pivotal Cloud Foundry:</p>
<ol>
<li><a href="https://github.com/SolaceSamples/solace-samples-cloudfoundry-java" target="_top">GitHub code for the Getting Started samples</a></li>
<li><a href="https://network.pivotal.io/products/solace-messaging" target="_top">How to download Solace Messaging for PCF</a></li>
<li><a href="http://docs.pivotal.io/solace-messaging/" target="_top">The Solace Messaging in PCF Documentation</a></li>
<li><a href="https://github.com/SolaceLabs/sl-cf-solace-messaging-demo" target="_top">A demo application using Solace Messaging for PCF</a></li>
<li><a href="http://docs.solace.com/Solace-Messaging-APIs/Best-Practices.htm" target="_top">Best Practices for developing applications that use Solace Messaging</a></li>
<li><a href="http://docs.solace.com/Solace-Messaging-APIs/Configuring-Connection-T.htm" target="_top">Configuring Connection Time-Outs and Retries</a></li>
</ol>
</div>
</div>
Expand Down
55 changes: 52 additions & 3 deletions docs/_tutorials/java-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The Pivotal Cloud Foundry environment exposes any bound Service Instances in a J
"clientPassword": "bb90fcb0-6c83-4a10-bafa-3ec225bbfc08",
"msgVpnName": "v005",
(...)
"smfHost": "tcp://192.168.132.14:7000",
"smfHosts": [ "tcp://192.168.132.14:7000" ],
(...)
}
}
Expand Down Expand Up @@ -153,8 +153,14 @@ logger.info("Solace client initializing and using Credentials: " + solaceCredent
Once the credentials are extracted, you can create and then connect the Solace Session in the conventional way as outlined in the [Publish/Subscribe tutorial]({{ site.links-pubsub-tutorial }}){:target="_top"}. You set the JCSMP properties and then use the `JCSMPFactory` to create a `Session`:

```java

// The host property is in a json array. Two hosts are provided in a High Availability
// environment, one for the primary router and one for the backup.
JSONArray hostsArray = solaceCredentials.getJSONArray("smfHosts");
String host = hostsArray.getString(0);

final JCSMPProperties properties = new JCSMPProperties();
properties.setProperty(JCSMPProperties.HOST, solaceCredentials.getString("smfHost"));
properties.setProperty(JCSMPProperties.HOST, host);
properties.setProperty(JCSMPProperties.VPN_NAME, solaceCredentials.getString("msgVpnName"));
properties.setProperty(JCSMPProperties.USERNAME, solaceCredentials.getString("clientUsername"));
properties.setProperty(JCSMPProperties.PASSWORD, solaceCredentials.getString("clientPassword"));
Expand Down Expand Up @@ -291,7 +297,7 @@ export APP_URL=`cf apps | grep $APP_NAME | grep started | awk '{ print $6}'`
echo "The application URL is: ${APP_URL}"
```

To demonstrate the application we will make the application send a message to itself. Then we will read the message back to confirm the successful delivery of the message :
To demonstrate Solace messaging, the application will send a message to itself. Then we will read the message back to confirm the successful delivery of the message:

```
# Subscribes the application to the topic "test"
Expand All @@ -303,3 +309,46 @@ curl -X POST -H "Content-Type: application/json;charset=UTF-8" -d '{"topic": "te
# The message should have been asynchronously received by the application. Check that the message was indeed received:
curl -X GET http://$APP_URL/message
```
## High Availability

Solace provides the option to set up High Availability configurations, where each message router has a backup. To use this in Cloud Foundry you need to create a service of type medium-ha or large-ha, for example:

```
cf create-service solace-messaging medium-ha solace-messaging-sample-instance
```

The Solace Java API automatically switches to the backup connection if it loses the connection to the primary router.

When using a High Availability service, the environment provided to the applications contains two connection urls rather than one. The first is the primary router and the second is the backup, for example:

```
"smfHosts": [ "tcp://192.168.101.16:7000", "tcp://192.168.101.17:7000" ]
```

In order to provide both hosts to the Solace Java API, you need to create a string containing a comma-separated list of the two hosts:

```
// The host property is in a json array. Two hosts are provided in a High Availability
// environment, one for the primary router and one for the backup.
JSONArray hostsArray = solaceCredentials.getJSONArray("smfHosts");
String primary = hostsArray.getString(0);
String backup = hostsArray.getString(1);
String hosts = String.join(",", primary, backup);
properties.setProperty(JCSMPProperties.HOST, hosts);
```
When you do the Spring Cloud tutorial, you will see that the Solace Spring Cloud Connector takes care of this for you.

Please consult the [Configuring Connections]({{ site.links-configuring-connection }}){:target="_top"} page.

As described in that document, when using High Availability it is recommended to set the following configuration:

```
JCSMPProperties properties = new JCSMPProperties();
JCSMPChannelProperties cp = (JCSMPChannelProperties) properties
.getProperty(JCSMPProperties.CLIENT_CHANNEL_PROPERTIES);
cp.setConnectRetries(1);
cp.setReconnectRetries(5);
cp.setReconnectRetryWaitInMillis(3000);
cp.setConnectRetriesPerHost(20);
```

6 changes: 0 additions & 6 deletions docs/_tutorials/secure-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ curl -X GET http://$APP_URL/message

## Common Problems

### JCSMPTransportException

If you see:

```
Expand All @@ -178,14 +176,10 @@ JCSMPTransportException: Error communicating with the router, ConnectException:

this can happen if a TLS server certificate was not configured in the Solace Messaging for PCF tile in which case the Solace Message Router will reject incoming TLS connections.

### CertificateException

If you see:
```
CertificateException: Path does not chain with any of the trust anchors
```

it is because the application could not validate the certificate it received from the Solace Message Router. This can happen when you install a self-signed certificate on the Solace Message Router, but didn't package it with the app, or didn't set INSTALL_CERTIFICATE to true in the sample.



6 changes: 5 additions & 1 deletion docs/_tutorials/spring-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The Pivotal Cloud Foundry environment exposes any bound Service Instances in a J
"clientPassword": "bb90fcb0-6c83-4a10-bafa-3ec225bbfc08",
"msgVpnName": "v005",
(...)
"smfHost": "tcp://192.168.132.14:7000",
"smfHosts": [ "tcp://192.168.132.14:7000" ],
(...)
}
}
Expand Down Expand Up @@ -140,6 +140,10 @@ try {
return;
}
```
Note that the VCAP_SERVICES environment variable contains a json array named smfHosts.
In a High Availability environment this will contain two hosts, the primary router and the backup.
The Spring Cloud connector automatically combines these into a single comma-separated string exposed
as the smfHost property, which is what the JCSMP library expects.

With the Solace session connected. The remainder of this tutorial is exactly the same as the [Java App]({{ site.baseurl }}/java-app) tutorial. The details are repeated here for convenience.

Expand Down
1 change: 1 addition & 0 deletions java-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jar {

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
Expand Down
Loading