All Projects → SolaceSamples → solace-samples-cloudfoundry-java

SolaceSamples / solace-samples-cloudfoundry-java

Licence: Apache-2.0 license
Samples showing how to connect and exchange messages with Solace Messaging for Pivotal Cloud Foundry.

Programming Languages

java
68154 projects - #9 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to solace-samples-cloudfoundry-java

solace-samples-mqtt
Getting Started Samples for using MQTT with Solace Message Routers.
Stars: ✭ 28 (-3.45%)
Mutual labels:  solace, solace-samples
solace-samples-javascript
Getting Started Samples for the Solace JavaScript API.
Stars: ✭ 26 (-10.34%)
Mutual labels:  solace, solace-samples
solace-samples-openmama
Tutorials for the Solace Transport Bridge of OpenMAMA
Stars: ✭ 19 (-34.48%)
Mutual labels:  solace, solace-samples
solace-samples-dotnet
Getting Started Samples for the Solace .NET API
Stars: ✭ 30 (+3.45%)
Mutual labels:  solace, solace-samples
solace-samples-jms
Getting Started Samples for the Solace JMS API.
Stars: ✭ 31 (+6.9%)
Mutual labels:  solace, solace-samples
solace-samples-rest-messaging
Tutorials show how to use the Solace REST Messaging API
Stars: ✭ 23 (-20.69%)
Mutual labels:  solace, solace-samples
Bosh Bootloader
Command line utility for standing up a BOSH director on an IAAS of your choice.
Stars: ✭ 171 (+489.66%)
Mutual labels:  cloud-foundry
Ng Demo
🦴 Bare Bones Angular 10 and Angular CLI Tutorial
Stars: ✭ 154 (+431.03%)
Mutual labels:  cloud-foundry
Kubo Release
Kubernetes BOSH release
Stars: ✭ 153 (+427.59%)
Mutual labels:  cloud-foundry
spring-petclinic-cloud
Fork of the Spring Cloud Microservices project packaged to be deployed on several Cloud platforms: Kubernetes and Cloud Foundry
Stars: ✭ 106 (+265.52%)
Mutual labels:  cloud-foundry
firehose exporter
Cloud Foundry Firehose Prometheus exporter
Stars: ✭ 27 (-6.9%)
Mutual labels:  cloud-foundry
Cli
The official command line client for Cloud Foundry
Stars: ✭ 1,613 (+5462.07%)
Mutual labels:  cloud-foundry
Ibm Cf V2
Use GitHub Actions to automatically deploy the latest version of V2Ray to IBM Cloud Foundry
Stars: ✭ 194 (+568.97%)
Mutual labels:  cloud-foundry
cf-cli-resource
Cloud Foundry CLI Concourse Resource
Stars: ✭ 46 (+58.62%)
Mutual labels:  cloud-foundry
btp-workflow-management-opensap
This repository contain the exercises for the openSAP course "Improve Business Processes with SAP Workflow Management."
Stars: ✭ 30 (+3.45%)
Mutual labels:  cloud-foundry
Gcp Service Broker
Open Service Broker for Google Cloud Platform
Stars: ✭ 133 (+358.62%)
Mutual labels:  cloud-foundry
Postfacto
Self-hosted retro tool aimed at helping remote teams
Stars: ✭ 224 (+672.41%)
Mutual labels:  cloud-foundry
Stratos
Stratos: Web-based Management UI for Cloud Foundry and Kubernetes
Stars: ✭ 209 (+620.69%)
Mutual labels:  cloud-foundry
Idea Live Templates
My IntelliJ Live Templates
Stars: ✭ 207 (+613.79%)
Mutual labels:  cloud-foundry
cf-rabbitmq-release
A BOSH Release of RabbitMQ
Stars: ✭ 29 (+0%)
Mutual labels:  cloud-foundry

Build Status

Getting Started Examples

Solace Cloud Foundry Java

The repository contains example applications that use the Solace Pubsub+ service on Pivotal Cloud Foundry. The goal of these sample applications is to illustrate various ways of consuming the VCAP_SERVICES environment variable from a Solace Pubsub+ Cloud Foundry service instance. You can get more details on the Solace Pubsub+ Service for Pivotal Cloud Foundry here.

This repository contains a sample application modified in the following ways:

  • Simple Java Application
  • Using Spring Cloud Connectors
  • Connecting using Transport Level Security

While not necessary for a Java Application or a straight Spring Cloud Connector applications, the samples in this repository still make use of of Spring Boot so they can easily expose a simple REST interface to provide interactive ways to subscribe, send and receive Solace messages. Spring Boot is not required. You can make use of the Spring Cloud Connectors in any Java Application. See the walk through tutorials for more details.

All of these sample applications have full walk through tutorials that explain the code in detail. Tutorials for each sample are available here:

What follows is a brief summary for people that want to dive straight into the code.

Common Setup

The sample applications specify a dependency on a Solace Pubsub+ service instance named solace-pubsub-sample-instance. To create the required Solace PubSub+ service instance, do the following:

cf create-service solace-pubsub shared solace-pubsub-sample-instance

Building

Just clone and build. For example:

  1. clone this GitHub repository
  2. ./gradlew build

Deploying

To deploy the individual applications to Cloud Foundry:

  1. cd to the project directory (java-app or spring-cloud)
  2. $ cf push

Java Application

application name: solace-sample-java-app

This application uses the Java library from http://www.JSON.org/ to parse the VCAP_SERVICES environment variable to determine the connection details for Solace PubSub+. For more details and example usage, see the walk through tutorial here:

Java Application using Spring Cloud Connector

application name: solace-sample-spring-cloud

This application makes use of the Spring Cloud Connectors project to automatically parse the VCAP_SERVICES environment variable. Applications do not have to be a Spring Boot application to make use of Spring Cloud Connectors. This example makes use of Spring Boot for convenience in enabling the simple REST API. In any Java Applications, simply specify the following dependencies in your build:

compile 'org.springframework.cloud:spring-cloud-spring-service-connector:1.2.3.RELEASE'
compile 'org.springframework.cloud:spring-cloud-cloudfoundry-connector:1.2.3.RELEASE'
compile 'com.solace.cloud.cloudfoundry:solace-spring-cloud-connector:2.1.+'

The solace-spring-cloud-connector is a Spring Cloud Connectors extension to parse the VCAP_SERVICES for the Solace PubSub+ service instance information. Check out the project page for more details:

The easiest way for applications to access the SolaceServiceCredentials object is by Service Id (ex: "MyService) as follows:

CloudFactory cloudFactory = new CloudFactory();
Cloud cloud = cloudFactory.getCloud();
SolaceServiceCredentials solaceServiceCredentials = (SolaceServiceCredentials) cloud.getServiceInfo("MyService");

Alternatively applications could search through the environment and discover matching services as follows:

SolaceServiceCredentials solaceServiceCredentials = null;
List<ServiceInfo> services = cloud.getServiceInfos();

// Connect to the first Solace PubSub+ service that is found in the services list.
for (ServiceInfo service : services) {
	if (service instanceof SolaceServiceCredentials) {
		solaceServiceCredentials = (SolaceServiceCredentials)service;
		break;
	}
}

For more details and example usage, see the walk through tutorial here:

Java Application using Java CFEnv

application name: solace-sample-spring-cloud-java-cfenv

This application makes use of the Java CFEnv project to automatically parse the VCAP_SERVICES environment variable. In any Java Applications, simply specify the following dependencies in your build:

compile 'com.solace.cloud.cloudfoundry:solace-java-cfenv'

The solace-java-cfenv is the successor to solace-spring-cloud-connector due to the deprecation of Spring Cloud Connectors. It is a Java CFEnv extension to parse the VCAP_SERVICES for the Solace PubSub+ service instance information. Check out the project page for more details:

To access the SolaceServiceCredentials object, applications must retrieve it in a manner similar to the following:

SolaceServiceCredentials solaceServiceCredentials = null;
List<SolaceServiceCredentials> solaceServiceCredentialsList = SolaceServiceCredentialsFactory.getAllFromCloudFoundry();

// Connect to the first Solace PubSub+ service that is found in the services list.
if (solaceServiceCredentialsList.size() > 0) {
    solaceServiceCredentials = solaceServiceCredentialsList.get(0);
}

Secure Session

application name: solace-sample-secure-session

This application is based on the Solace Java CFEnv described above, but shows how to use Transport Level Security (TLS) between the Java application and the Solace PubSub+ Service Instance.

LDAP

This is not a standalone application, but instead a modification to the existing sample apps.

If application access is enabled by the cloud operator, bindings will not contain application access credentials and the credentials will instead have to be provided to the application externally.

This manifests as the service instance owner having to manually configure LDAP authorization groups for application access.

Try out the Applications

The sample applications have a simple REST interface that allows you to subscribe, send and receive Solace messages. You can try the applications out using command like the following.

Determine the URL of the sample application and export it for use in the curl commands. Adjust the app name as appropriate to match the sample you're using:

export APP_NAME=solace-sample-java-app
export APP_URL=`cf apps | grep $APP_NAME | grep started | awk '{ print $6}'`
echo "The application URL is: ${APP_URL}"

Subscribe to topic "test"

curl -X POST -H "Content-Type: application/json;charset=UTF-8" -d '{"subscription": "test"}' http://$APP_URL/subscription

Send message with topic "test"

curl -X POST -H "Content-Type: application/json;charset=UTF-8" -d '{"topic": "test", "body": "TEST_MESSAGE"}' http://$APP_URL/message

The message is received asynchronously, check for the last message.

curl -X GET http://$APP_URL/message

Unsubscribe the application from topic "test"

curl -X DELETE http://$APP_URL/subscription/test

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

See the list of contributors who participated in this project.

License

This project is licensed under the Apache License, Version 2.0. - See the LICENSE file for details.

Resources

For more information try these resources:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].