http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/perf/src/main/java/org/hornetq/core/example/PerfParams.java ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/java/org/hornetq/core/example/PerfParams.java b/examples/core/perf/src/main/java/org/hornetq/core/example/PerfParams.java new file mode 100644 index 0000000..738fe9a --- /dev/null +++ b/examples/core/perf/src/main/java/org/hornetq/core/example/PerfParams.java @@ -0,0 +1,299 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.hornetq.core.example; + +import java.io.Serializable; + +/** + * + * Class that holds the parameters used in the performance examples + * + * @author <a href="[email protected]">Andy Taylor</a> + */ +public class PerfParams implements Serializable +{ + private static final long serialVersionUID = -4336539641012356002L; + + private int noOfMessagesToSend = 1000; + + private int noOfWarmupMessages; + + private int messageSize = 1024; // in bytes + + private boolean durable = false; + + private boolean isSessionTransacted = false; + + private int batchSize = 5000; + + private boolean drainQueue = true; + + private String queueName; + + private String address; + + private int throttleRate; + + private String host; + + private int port; + + private int tcpBufferSize; + + private boolean tcpNoDelay; + + private boolean preAck; + + private int confirmationWindow = -1; + + private int producerWindow; + + private int consumerWindow; + + private boolean blockOnPersistent = true; + + private boolean blockOnACK = true; + + private boolean useSendAcks; + + public boolean isBlockOnPersistent() + { + return blockOnPersistent; + } + + public void setBlockOnPersistent(final boolean blockOnPersistent) + { + this.blockOnPersistent = blockOnPersistent; + } + + public boolean isBlockOnACK() + { + return blockOnACK; + } + + public void setBlockOnACK(final boolean blockOnACK) + { + this.blockOnACK = blockOnACK; + } + + public int getNoOfMessagesToSend() + { + return noOfMessagesToSend; + } + + public void setNoOfMessagesToSend(final int noOfMessagesToSend) + { + this.noOfMessagesToSend = noOfMessagesToSend; + } + + public int getNoOfWarmupMessages() + { + return noOfWarmupMessages; + } + + public void setNoOfWarmupMessages(final int noOfWarmupMessages) + { + this.noOfWarmupMessages = noOfWarmupMessages; + } + + public int getMessageSize() + { + return messageSize; + } + + public void setMessageSize(final int messageSize) + { + this.messageSize = messageSize; + } + + public boolean isDurable() + { + return durable; + } + + public void setDurable(final boolean durable) + { + this.durable = durable; + } + + public boolean isSessionTransacted() + { + return isSessionTransacted; + } + + public void setSessionTransacted(final boolean sessionTransacted) + { + isSessionTransacted = sessionTransacted; + } + + public int getBatchSize() + { + return batchSize; + } + + public void setBatchSize(final int batchSize) + { + this.batchSize = batchSize; + } + + public boolean isDrainQueue() + { + return drainQueue; + } + + public void setDrainQueue(final boolean drainQueue) + { + this.drainQueue = drainQueue; + } + + public String getQueueName() + { + return queueName; + } + + public void setQueueName(final String queueName) + { + this.queueName = queueName; + } + + public String getAddress() + { + return address; + } + + public void setAddress(final String address) + { + this.address = address; + } + + public int getThrottleRate() + { + return throttleRate; + } + + public void setThrottleRate(final int throttleRate) + { + this.throttleRate = throttleRate; + } + + @Override + public String toString() + { + return "message to send = " + noOfMessagesToSend + + ", Durable = " + + durable + + ", session transacted = " + + isSessionTransacted + + (isSessionTransacted ? ", transaction batch size = " + batchSize : "") + + ", drain queue = " + + drainQueue + + ", queue name = " + + queueName + + ", Throttle rate = " + + throttleRate + + ", blockOnPersistent = " + + blockOnPersistent + + ". blockOnACK = " + + blockOnACK; + } + + public synchronized String getHost() + { + return host; + } + + public synchronized void setHost(final String host) + { + this.host = host; + } + + public synchronized int getPort() + { + return port; + } + + public synchronized void setPort(final int port) + { + this.port = port; + } + + public synchronized int getTcpBufferSize() + { + return tcpBufferSize; + } + + public synchronized void setTcpBufferSize(final int tcpBufferSize) + { + this.tcpBufferSize = tcpBufferSize; + } + + public synchronized boolean isTcpNoDelay() + { + return tcpNoDelay; + } + + public synchronized void setTcpNoDelay(final boolean tcpNoDelay) + { + this.tcpNoDelay = tcpNoDelay; + } + + public synchronized boolean isPreAck() + { + return preAck; + } + + public synchronized void setPreAck(final boolean preAck) + { + this.preAck = preAck; + } + + public synchronized int getConfirmationWindow() + { + return confirmationWindow; + } + + public synchronized void setConfirmationWindow(final int confirmationWindow) + { + this.confirmationWindow = confirmationWindow; + } + + public int getProducerWindow() + { + return producerWindow; + } + + public void setProducerWindow(final int producerWindow) + { + this.producerWindow = producerWindow; + } + + public int getConsumerWindow() + { + return consumerWindow; + } + + public void setConsumerWindow(final int consumerWindow) + { + this.consumerWindow = consumerWindow; + } + + public boolean isUseSendAcks() + { + return useSendAcks; + } + + public void setUseSendAcks(boolean useSendAcks) + { + this.useSendAcks = useSendAcks; + } +}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/perf/src/main/java/org/hornetq/core/example/PerfSender.java ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/java/org/hornetq/core/example/PerfSender.java b/examples/core/perf/src/main/java/org/hornetq/core/example/PerfSender.java new file mode 100644 index 0000000..9c86a4f --- /dev/null +++ b/examples/core/perf/src/main/java/org/hornetq/core/example/PerfSender.java @@ -0,0 +1,55 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.hornetq.core.example; + +import java.util.logging.Logger; + +/** + * + * A PerfSender + * + * @author <a href="mailto:[email protected]">Tim Fox</a> + * + * + */ +public class PerfSender extends PerfBase +{ + private static final Logger log = Logger.getLogger(PerfSender.class.getName()); + + public static void main(final String[] args) + { + try + { + String fileName = PerfBase.getPerfFileName(args); + + PerfParams params = PerfBase.getParams(fileName); + + new PerfSender(params).run(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + private PerfSender(final PerfParams perfParams) + { + super(perfParams); + } + + public void run() throws Exception + { + runSender(); + } + +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/perf/src/main/resources/server0/hornetq-beans.xml ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/resources/server0/hornetq-beans.xml b/examples/core/perf/src/main/resources/server0/hornetq-beans.xml new file mode 100644 index 0000000..1ab8e95 --- /dev/null +++ b/examples/core/perf/src/main/resources/server0/hornetq-beans.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<deployment xmlns="urn:jboss:bean-deployer:2.0"> + + <!-- The core configuration --> + <bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration"/> + + <!-- The core server --> + <bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl"> + <constructor> + <parameter> + <inject bean="Configuration"/> + </parameter> + </constructor> + </bean> + +</deployment> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/perf/src/main/resources/server0/hornetq-configuration-messaging-lab.xml ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/resources/server0/hornetq-configuration-messaging-lab.xml b/examples/core/perf/src/main/resources/server0/hornetq-configuration-messaging-lab.xml new file mode 100644 index 0000000..514766e --- /dev/null +++ b/examples/core/perf/src/main/resources/server0/hornetq-configuration-messaging-lab.xml @@ -0,0 +1,40 @@ +<configuration xmlns="urn:hornetq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd"> + + + + <bindings-directory>${build.directory}/server0/data/messaging/bindings</bindings-directory> + + <journal-directory>${build.directory}/server0/data/messaging/journal</journal-directory> + + <large-messages-directory>${build.directory}/server0/data/messaging/largemessages</large-messages-directory> + + <paging-directory>${build.directory}/server0/data/messaging/paging</paging-directory> + <!-- Acceptors --> + <acceptors> + <acceptor name="netty-acceptor"> + <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class> + <param key="tcp-no-delay" value="false"/> + <param key="tcp-send-buffer-size" value="1048576"/> + <param key="tcp-receive-buffer-size" value="1048576"/> + <param key="host" value="172.16.8.10"/> + </acceptor> + </acceptors> + + <security-enabled>false</security-enabled> + + <persistence-enabled>true</persistence-enabled> + + <large-messages-directory>/hornetq-data/large-messages</large-messages-directory> + <bindings-directory>/hornetq-data/bindings</bindings-directory> + <journal-directory>/hornetq-data/journal</journal-directory> + <paging-directory>/hornetq-data/paging</paging-directory> + + <queues> + <queue name="perfQueue"> + <address>perfAddress</address> + </queue> + </queues> + +</configuration> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/perf/src/main/resources/server0/hornetq-configuration.xml ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/resources/server0/hornetq-configuration.xml b/examples/core/perf/src/main/resources/server0/hornetq-configuration.xml new file mode 100644 index 0000000..3ad5b50 --- /dev/null +++ b/examples/core/perf/src/main/resources/server0/hornetq-configuration.xml @@ -0,0 +1,53 @@ +<configuration xmlns="urn:hornetq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd"> + + + + <bindings-directory>target/server0/data/messaging/bindings</bindings-directory> + + <journal-directory>target/server0/data/messaging/journal</journal-directory> + + <large-messages-directory>target/server0/data/messaging/largemessages</large-messages-directory> + + <paging-directory>target/server0/data/messaging/paging</paging-directory> + <!-- Acceptors --> + <acceptors> + <acceptor name="netty-acceptor"> + <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class> + <param key="tcp-no-delay" value="false"/> + <param key="tcp-send-buffer-size" value="1048576"/> + <param key="tcp-receive-buffer-size" value="1048576"/> + </acceptor> + </acceptors> + + <security-enabled>false</security-enabled> + + <persistence-enabled>true</persistence-enabled> + + <journal-sync-non-transactional>true</journal-sync-non-transactional> + <journal-sync-transactional>true</journal-sync-transactional> + <journal-type>ASYNCIO</journal-type> + <journal-min-files>20</journal-min-files> + <journal-buffer-timeout>20000</journal-buffer-timeout> + <log-journal-write-rate>false</log-journal-write-rate> + <run-sync-speed-test>false</run-sync-speed-test> + + <!-- <perf-blast-pages>5000</perf-blast-pages> --> + + <queues> + <queue name="perfQueue"> + <address>perfAddress</address> + </queue> + </queues> + +<!-- + <address-settings> + <address-setting match="perfAddress"> + <max-size-bytes>10485760</max-size-bytes> + <address-full-policy>BLOCK</address-full-policy> + </address-setting> + </address-settings> +--> + +</configuration> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/pom.xml ---------------------------------------------------------------------- diff --git a/examples/core/pom.xml b/examples/core/pom.xml new file mode 100644 index 0000000..c70dcd1 --- /dev/null +++ b/examples/core/pom.xml @@ -0,0 +1,20 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.hornetq.examples</groupId> + <artifactId>hornetq-examples</artifactId> + <version>2.5.0-SNAPSHOT</version> + </parent> + + <groupId>org.hornetq.examples.core</groupId> + <artifactId>core-examples</artifactId> + <packaging>pom</packaging> + <name>HornetQ Core Examples</name> + + <properties> + <udp-address>231.7.7.7</udp-address> + </properties> + +</project> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/twitter-connector/pom.xml ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/pom.xml b/examples/core/twitter-connector/pom.xml new file mode 100644 index 0000000..eb4d3a3 --- /dev/null +++ b/examples/core/twitter-connector/pom.xml @@ -0,0 +1,184 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.hornetq.examples.core</groupId> + <artifactId>core-examples</artifactId> + <version>2.5.0-SNAPSHOT</version> + </parent> + + <artifactId>hornetq-twitter-example</artifactId> + <packaging>jar</packaging> + <name>HornetQ Twitter Example</name> + + <properties> + <TWITTER_CONSUMER_KEY>consumerKey</TWITTER_CONSUMER_KEY> + <TWITTER_CONSUMER_SECRET>consumerSecret</TWITTER_CONSUMER_SECRET> + <TWITTER_ACCESS_TOKEN>twitterAccess</TWITTER_ACCESS_TOKEN> + <TWITTER_ACCESS_TOKEN_SECRET>twitterToken</TWITTER_ACCESS_TOKEN_SECRET> + </properties> + <dependencies> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-server</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-core-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-commons</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-all</artifactId> + <version>${netty.version}</version> + </dependency> + <dependency> + <groupId>org.jboss.javaee</groupId> + <artifactId>jboss-jms-api</artifactId> + <version>1.1.0.GA</version> + </dependency> + <dependency> + <groupId>org.jboss.naming</groupId> + <artifactId>jnp-client</artifactId> + <version>5.0.5.Final</version> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.jms</groupId> + <artifactId>jboss-jms-api_2.0_spec</artifactId> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-maven-plugin</artifactId> + <executions> + <execution> + <id>start</id> + <goals> + <goal>start</goal> + </goals> + <configuration> + <waitOnStart>true</waitOnStart> + <hornetqConfigurationDir>${basedir}/target/classes/server0</hornetqConfigurationDir> + <systemProperties> + <property> + <name>build.directory</name> + <value>${basedir}/target/</value> + </property> + <property> + <name>TWITTER_CONSUMER_KEY</name> + <value>${TWITTER_CONSUMER_KEY}</value> + </property> + <property> + <name>TWITTER_CONSUMER_SECRET</name> + <value>${TWITTER_CONSUMER_SECRET}</value> + </property> + <property> + <name>TWITTER_ACCESS_TOKEN</name> + <value>${TWITTER_ACCESS_TOKEN}</value> + </property> + <property> + <name>TWITTER_ACCESS_TOKEN_SECRET</name> + <value>${TWITTER_ACCESS_TOKEN_SECRET}</value> + </property> + </systemProperties> + </configuration> + </execution> + </executions> + <configuration> + <waitOnStart>false</waitOnStart> + <hornetqConfigurationDir>${basedir}/target/classes/server0</hornetqConfigurationDir> + </configuration> + <dependencies> + <dependency> + <groupId>org.hornetq.examples.core</groupId> + <artifactId>hornetq-twitter-example</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-twitter-integration</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-core-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-server</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-jms-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-jms-server</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-all</artifactId> + <version>${netty.version}</version> + </dependency> + <dependency> + <groupId>org.jboss.javaee</groupId> + <artifactId>jboss-jms-api</artifactId> + <version>1.1.0.GA</version> + </dependency> + <dependency> + <groupId>org.jboss.naming</groupId> + <artifactId>jnpserver</artifactId> + <version>5.0.3.GA</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>example</id> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>java</goal> + </goals> + </execution> + </executions> + <configuration> + <mainClass>org.hornetq.core.example.TwitterConnectorExample</mainClass> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/twitter-connector/readme.html ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/readme.html b/examples/core/twitter-connector/readme.html new file mode 100644 index 0000000..7addfb4 --- /dev/null +++ b/examples/core/twitter-connector/readme.html @@ -0,0 +1,96 @@ +<html> + <head> + <title>HornetQ Twitter Connector Service Example</title> + <link rel="stylesheet" type="text/css" href="../../common/common.css" /> + <link rel="stylesheet" type="text/css" href="../../common/prettify.css" /> + <script type="text/javascript" src="../../common/prettify.js"></script> + </head> + <body onload="prettyPrint()"> + <h1>Twitter Connector Service Example</h1> + + <p>This example shows you how to configure HornetQ to use the Twitter Connector Service.</p> + + <p>HornetQ supports 2 types of Twitter connector, incoming and outgoing. + Incoming connector consumes from twitter and forwards to a configurable address. + Outgoing connector consumes from a configurable address and forwards to twitter. + </p> + + <p>In this example, incoming connector and outgoing connector is related to same twitter account. + So if you send a message to an outgoing address, outgoing connector forwards it to twitter, + and then incoming connector consumes it and forwards to incoming address.</p> + + <h2>Example step-by-step</h2> + <p><i>To run the server, simply type <code>mvn-Dtwitter.consumerKey=consumer -Dtwitter.consumerSecret=secret -Dtwitter.accessToken=token -Dtwitter.accessTokenSecret=secret verify</code> + from this directory but replacing the system properties with those of the twitter account you want to use. Then run the example + by using the command <code>mvn -Pexample package</code></p> + + + <ol> + <li>First we need to create a ClientSessionFactory with Netty transport configuration</li> + <pre class="prettyprint"> + <code>csf = HornetQClient.createClientSessionFactory(new TransportConfiguration(NettyConnectorFactory.class.getName()));</code> + </pre> + + <li>We create a core session with auto-commit mode</li> + <pre class="prettyprint"> + <code>session = csf.createSession(true,true);</code> + </pre> + + <li>We Create a core producer for queue.outgoingQueue</li> + <pre class="prettyprint"> + <code>ClientProducer cp = session.createProducer(OUTGOING_QUEUE);</code> + </pre> + + <li>We create a core consumer for queue.incomingQueue</li> + <pre class="prettyprint"> + <code>ClientConsumer cc = session.createConsumer(INCOMING_QUEUE);</code> + </pre> + + <li>We create a core message that we are going to send</li> + <pre class="prettyprint"> + <code>ClientMessage cm = session.createMessage(org.hornetq.api.core.Message.TEXT_TYPE,true); +String testMessage = System.currentTimeMillis() + ": twitter connector test example"; +cm.getBodyBuffer().writeString(testMessage);</code> + </pre> + + <li>We send the message to queue.outgoingQueue</li> + <pre class="prettyprint"> + <code>cp.send(cm);</code> + </pre> + + <li>We start the session</li> + <pre class="prettyprint"> + <code>session.start();</code> + </pre> + + <li>We will receive a message from queue.incomingQueue. + Outgoing connector forwards a message(we sent before) to twitter immediately. + Since incoming connector consumes from twitter and forwards to queue.incomingQueue + every 60 seconds, It will be received in 60+x seconds.</li> + <pre class="prettyprint"> + <code>ClientMessage received = cc.receive(70 * 1000); +received.acknowledge(); +String receivedText = received.getBodyBuffer().readString();</code> + </pre> + + <li>And finally, remember to close core session and ClientSessionFactory in a <code>finally</code> block.</li> + + <pre class="prettyprint"> + <code>finally +{ + if(session != null) + { + session.close(); + } + if(csf != null) + { + csf.close(); + } +}</code> + </pre> + + + + </ol> + </body> +</html> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/twitter-connector/src/main/java/org/hornetq/core/example/TwitterConnectorExample.java ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/src/main/java/org/hornetq/core/example/TwitterConnectorExample.java b/examples/core/twitter-connector/src/main/java/org/hornetq/core/example/TwitterConnectorExample.java new file mode 100644 index 0000000..37274d1 --- /dev/null +++ b/examples/core/twitter-connector/src/main/java/org/hornetq/core/example/TwitterConnectorExample.java @@ -0,0 +1,117 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.hornetq.core.example; + +import org.hornetq.api.core.TransportConfiguration; +import org.hornetq.api.core.client.ClientConsumer; +import org.hornetq.api.core.client.ClientMessage; +import org.hornetq.api.core.client.ClientProducer; +import org.hornetq.api.core.client.ClientSession; +import org.hornetq.api.core.client.ClientSessionFactory; +import org.hornetq.api.core.client.HornetQClient; +import org.hornetq.api.core.client.ServerLocator; +import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory; + +/** + * A simple example of using twitter connector service. + * + * @author <a href="[email protected]">Tomohisa Igarashi</a> + */ +public class TwitterConnectorExample +{ + private static final String INCOMING_QUEUE = "queue.incomingQueue"; + private static final String OUTGOING_QUEUE = "queue.outgoingQueue"; + + public static void main(final String[] args) throws Exception + { + ServerLocator locator = null; + ClientSessionFactory csf = null; + ClientSession session = null; + try + { + String testMessage = System.currentTimeMillis() + ": " + System.getProperty("twitter.example.alternativeMessage"); + if(testMessage == null || testMessage.trim().equals("")) { + testMessage = System.currentTimeMillis() + ": ### Hello, HornetQ fans!! We are now experiencing so fast, so reliable and so exciting messaging never seen before ;-) ###"; + } + + // Step 1. Create a ClientSessionFactory + + + locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName())); + + csf = locator.createSessionFactory(); + + // Step 2. Create a core session. + session = csf.createSession(true,true); + + // Step 3. Create a core producer for queue.outgoingQueue. + ClientProducer cp = session.createProducer(OUTGOING_QUEUE); + + // Step 4. Create a core consumer for queue.incomingQueue. + ClientConsumer cc = session.createConsumer(INCOMING_QUEUE); + + // Step 5. Create a core message. + ClientMessage cm = session.createMessage(org.hornetq.api.core.Message.TEXT_TYPE,true); + cm.getBodyBuffer().writeString(testMessage); + + // Step 6. Send a message to queue.outgoingQueue. + cp.send(cm); + System.out.println("#### Sent a message to " + OUTGOING_QUEUE + ": " + testMessage); + + // Step 7. Start the session. + session.start(); + + // Step 8. Receive a message from queue.incomingQueue. + // Outgoing connector forwards a message(sent at Step 6.) to twitter immediately. + // Since incoming connector consumes from twitter and forwards to queue.incomingQueue + // every 60 seconds, It will be received in 60+x seconds. + System.out.println("#### A message will be received in 60 seconds. Please wait..."); + ClientMessage received = cc.receive(70 * 1000); + received.acknowledge(); + String receivedText = received.getBodyBuffer().readString(); + + while(!receivedText.equals(testMessage)) + { + // ignoring other tweets + received = cc.receiveImmediate(); + if(received == null) { + // no other tweets. test message has gone... + return; + } + + received.acknowledge(); + receivedText = received.getBodyBuffer().readString(); + } + + System.out.println("#### Received a message from " + INCOMING_QUEUE + ": " + receivedText); + } + finally + { + // Step 9. Be sure to close some resources. + if(session != null) + { + session.close(); + } + if(csf != null) + { + csf.close(); + } + + if (locator != null) + { + locator.close(); + } + } + } + +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/twitter-connector/src/main/resources/server0/hornetq-beans.xml ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/src/main/resources/server0/hornetq-beans.xml b/examples/core/twitter-connector/src/main/resources/server0/hornetq-beans.xml new file mode 100644 index 0000000..171d373 --- /dev/null +++ b/examples/core/twitter-connector/src/main/resources/server0/hornetq-beans.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<deployment xmlns="urn:jboss:bean-deployer:2.0"> + + <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/> + + <!-- JNDI server. Disable this if you don't want JNDI --> + <bean name="JNDIServer" class="org.jnp.server.Main"> + <property name="namingInfo"> + <inject bean="Naming"/> + </property> + <property name="port">1099</property> + <property name="bindAddress">localhost</property> + <property name="rmiPort">1098</property> + <property name="rmiBindAddress">localhost</property> + </bean> + + <!-- MBean server --> + <bean name="MBeanServer" class="javax.management.MBeanServer"> + <constructor factoryClass="java.lang.management.ManagementFactory" + factoryMethod="getPlatformMBeanServer"/> + </bean> + + <!-- The core configuration --> + <bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration"/> + + <!-- The security manager --> + <bean name="HornetQSecurityManager" class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl"> + <start ignored="true"/> + <stop ignored="true"/> + </bean> + + <!-- The core server --> + <bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl"> + <constructor> + <parameter> + <inject bean="Configuration"/> + </parameter> + <parameter> + <inject bean="MBeanServer"/> + </parameter> + <parameter> + <inject bean="HornetQSecurityManager"/> + </parameter> + </constructor> + <start ignored="true"/> + <stop ignored="true"/> + </bean> + + <!-- The JMS server --> + <bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl"> + <constructor> + <parameter> + <inject bean="HornetQServer"/> + </parameter> + </constructor> + </bean> + +</deployment> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/twitter-connector/src/main/resources/server0/hornetq-configuration.xml ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/src/main/resources/server0/hornetq-configuration.xml b/examples/core/twitter-connector/src/main/resources/server0/hornetq-configuration.xml new file mode 100644 index 0000000..83cc843 --- /dev/null +++ b/examples/core/twitter-connector/src/main/resources/server0/hornetq-configuration.xml @@ -0,0 +1,71 @@ +<configuration xmlns="urn:hornetq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd"> + + + <bindings-directory>target/server0/data/messaging/bindings</bindings-directory> + + <journal-directory>target/server0/data/messaging/journal</journal-directory> + + <large-messages-directory>target/server0/data/messaging/largemessages</large-messages-directory> + + <paging-directory>target/server0/data/messaging/paging</paging-directory> + <!-- Connectors --> + + <connectors> + <connector name="netty-connector"> + <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class> + </connector> + </connectors> + + <!-- Acceptors --> + <acceptors> + <acceptor name="netty-acceptor"> + <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class> + </acceptor> + </acceptors> + + <!-- Other config --> + + <security-settings> + <!--security for example queue--> + <security-setting match="queue.incomingQueue"> + <permission type="consume" roles="guest"/> + <permission type="send" roles="guest"/> + </security-setting> + <security-setting match="queue.outgoingQueue"> + <permission type="consume" roles="guest"/> + <permission type="send" roles="guest"/> + </security-setting> + </security-settings> + + <queues> + <queue name="queue.incomingQueue"> + <address>queue.incomingQueue</address> + </queue> + <queue name="queue.outgoingQueue"> + <address>queue.outgoingQueue</address> + </queue> + </queues> + + <connector-services> + <connector-service name="my-incoming-tweets"> + <factory-class>org.hornetq.integration.twitter.TwitterIncomingConnectorServiceFactory</factory-class> + <param key="queue" value="queue.incomingQueue"/> + <param key="consumerKey" value="${twitter.consumerKey}"/> + <param key="consumerSecret" value="${twitter.consumerSecret}"/> + <param key="accessToken" value="${twitter.accessToken}"/> + <param key="accessTokenSecret" value="${twitter.accessTokenSecret}"/> + <param key="interval" value="60"/> + </connector-service> + <connector-service name="my-outgoing-tweets"> + <factory-class>org.hornetq.integration.twitter.TwitterOutgoingConnectorServiceFactory</factory-class> + <param key="queue" value="queue.outgoingQueue"/> + <param key="consumerKey" value="${twitter.consumerKey}"/> + <param key="consumerSecret" value="${twitter.consumerSecret}"/> + <param key="accessToken" value="${twitter.accessToken}"/> + <param key="accessTokenSecret" value="${twitter.accessTokenSecret}"/> + </connector-service> + </connector-services> + +</configuration> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/twitter-connector/src/main/resources/server0/hornetq-jms.xml ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/src/main/resources/server0/hornetq-jms.xml b/examples/core/twitter-connector/src/main/resources/server0/hornetq-jms.xml new file mode 100644 index 0000000..678e7f5 --- /dev/null +++ b/examples/core/twitter-connector/src/main/resources/server0/hornetq-jms.xml @@ -0,0 +1,19 @@ +<configuration xmlns="urn:hornetq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd"> + <!--the connection factory used by the example--> + <connection-factory name="ConnectionFactory"> + <connectors> + <connector-ref connector-name="netty-connector"/> + </connectors> + <entries> + <entry name="ConnectionFactory"/> + </entries> + </connection-factory> + + <!--the queue used by the example--> + <queue name="exampleQueue"> + <entry name="/queue/exampleQueue"/> + </queue> + +</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/twitter-connector/src/main/resources/server0/hornetq-users.xml ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/src/main/resources/server0/hornetq-users.xml b/examples/core/twitter-connector/src/main/resources/server0/hornetq-users.xml new file mode 100644 index 0000000..934306c --- /dev/null +++ b/examples/core/twitter-connector/src/main/resources/server0/hornetq-users.xml @@ -0,0 +1,7 @@ +<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd"> + <!-- the default user. this is used where username is null--> + <defaultuser name="guest" password="guest"> + <role name="guest"/> + </defaultuser> +</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/vertx-connector/pom.xml ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/pom.xml b/examples/core/vertx-connector/pom.xml new file mode 100644 index 0000000..a2cc7f3 --- /dev/null +++ b/examples/core/vertx-connector/pom.xml @@ -0,0 +1,181 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.hornetq.examples.core</groupId> + <artifactId>core-examples</artifactId> + <version>2.5.0-SNAPSHOT</version> + </parent> + + <artifactId>hornetq-vertx-example</artifactId> + <packaging>jar</packaging> + <name>HornetQ Vert.x Example</name> + + <properties> + <vertx.version>2.1RC1</vertx.version> + </properties> + <dependencies> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-server</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-core-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-commons</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-all</artifactId> + <version>${netty.version}</version> + </dependency> + <dependency> + <groupId>org.jboss.javaee</groupId> + <artifactId>jboss-jms-api</artifactId> + <version>1.1.0.GA</version> + </dependency> + <dependency> + <groupId>org.jboss.naming</groupId> + <artifactId>jnp-client</artifactId> + <version>5.0.5.Final</version> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.jms</groupId> + <artifactId>jboss-jms-api_2.0_spec</artifactId> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-core</artifactId> + <version>${vertx.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-platform</artifactId> + <version>${vertx.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-hazelcast</artifactId> + <version>${vertx.version}</version> + <scope>provided</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-maven-plugin</artifactId> + <executions> + <execution> + <id>start</id> + <goals> + <goal>start</goal> + </goals> + <configuration> + <systemProperties> + <property> + <name>build.directory</name> + <value>${basedir}/target/</value> + </property> + </systemProperties> + </configuration> + </execution> + <execution> + <id>runClient</id> + <goals> + <goal>runClient</goal> + </goals> + <configuration> + <clientClass>org.hornetq.core.example.VertxConnectorExample</clientClass> + </configuration> + </execution> + <execution> + <id>stop</id> + <goals> + <goal>stop</goal> + </goals> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.hornetq.examples.core</groupId> + <artifactId>hornetq-vertx-example</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-vertx-integration</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-core-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-server</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-jms-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hornetq</groupId> + <artifactId>hornetq-jms-server</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-all</artifactId> + <version>${netty.version}</version> + </dependency> + <dependency> + <groupId>org.jboss.javaee</groupId> + <artifactId>jboss-jms-api</artifactId> + <version>1.1.0.GA</version> + </dependency> + <dependency> + <groupId>org.jboss.naming</groupId> + <artifactId>jnpserver</artifactId> + <version>5.0.3.GA</version> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-core</artifactId> + <version>${vertx.version}</version> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-platform</artifactId> + <version>${vertx.version}</version> + </dependency> + <dependency> + <groupId>io.vertx</groupId> + <artifactId>vertx-hazelcast</artifactId> + <version>${vertx.version}</version> + </dependency> + </dependencies> + <configuration> + <waitOnStart>false</waitOnStart> + <hornetqConfigurationDir>${basedir}/target/classes/server0</hornetqConfigurationDir> + </configuration> + </plugin> + </plugins> + </build> + + +</project> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/vertx-connector/readme.html ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/readme.html b/examples/core/vertx-connector/readme.html new file mode 100644 index 0000000..59538f9 --- /dev/null +++ b/examples/core/vertx-connector/readme.html @@ -0,0 +1,84 @@ +<html> + <head> + <title>HornetQ Vert.x Connector Service Example</title> + <link rel="stylesheet" type="text/css" href="../../common/common.css" /> + <link rel="stylesheet" type="text/css" href="../../common/prettify.css" /> + <script type="text/javascript" src="../../common/prettify.js"></script> + </head> + <body onload="prettyPrint()"> + <h1>Vert.x Connector Service Example</h1> + + <p>This example shows you how to configure HornetQ to use the Vert.x Connector Service.</p> + + <p>HornetQ supports 2 types of Vert.x connector, incoming and outgoing. + Incoming connector consumes from Vert.x event bus and forwards to a configurable address. + Outgoing connector consumes from a configurable address and forwards to a configurable Vert.x event bus. + </p> + + <p>In this example, an incoming connector and an outgoing connector are configured. A simple java Verticle + is deployed. The verticle registers a message handler on the outgoing connector's address ("outgoing.vertx.address"). + A String message is sent to Vert.x event bus on the incoming connector's address("incoming.vertx.address"). + The message then will be forwarded to a HornetQ queue by the incoming connector. The outgoing connector listens to + the HornetQ queue and forwards the message from HornetQ to Vert.x event bus on the outgoing connector's address. + The verticle finally receives the message from it's event bus.</p> + + <p>For more information on Vert.x concept please visit the <a href="http://vertx.io/">Vertx site</a></p> + + <h2>Example step-by-step</h2> + <p><i>To run the server, simply type <code>mvn verify</code> + from this directory.</p> + + <ol> + <li>First we need to create a Vert.x PlatformManager</li> + <pre class="prettyprint"> + <code>platformManager = PlatformLocator.factory.createPlatformManager(PORT, HOST);</code> + </pre> + + <li>We deploy a Verticle using the platformManager</li> + <pre class="prettyprint"> + <code>String verticle = "org.hornetq.core.example.ExampleVerticle"; + platformManager.deployVerticle(verticle, null, new URL[0], 1, null, + new Handler<AsyncResult<String>>(){ + + @Override + public void handle(AsyncResult<String> result) + { + if (!result.succeeded()) + { + throw new RuntimeException("failed to deploy verticle", result.cause()); + } + latch0.countDown(); + } + + });</code> + </pre> + + <li>We register a message handler with the event bus in the Verticle to listen on the outgoing connector's address.</li> + <pre class="prettyprint"> + <code>EventBus eventBus = vertx.eventBus(); + eventBus.registerHandler(VertxConnectorExample.OUTGOING, + new Handler<Message<?>>() { + @Override + public void handle(Message<?> startMsg) + { + Object body = startMsg.body(); + System.out.println("Verticle receives a message: " + body); + VertxConnectorExample.result.set(VertxConnectorExample.MSG.equals(body)); + latch0.countDown(); + } + }); + </code> + </pre> + + <li>We send a message to incoming connector's address via event bus</li> + <pre class="prettyprint"> + <code> + EventBus bus = platformManager.vertx().eventBus(); + bus.send(INCOMING, MSG); + </code> + </pre> + + <li>The message will eventually arrives at the Verticle's message handler.</li> + </ol> + </body> +</html> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/vertx-connector/src/main/java/org/hornetq/core/example/ExampleVerticle.java ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/src/main/java/org/hornetq/core/example/ExampleVerticle.java b/examples/core/vertx-connector/src/main/java/org/hornetq/core/example/ExampleVerticle.java new file mode 100644 index 0000000..9438434 --- /dev/null +++ b/examples/core/vertx-connector/src/main/java/org/hornetq/core/example/ExampleVerticle.java @@ -0,0 +1,55 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.hornetq.core.example; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.vertx.java.core.Handler; +import org.vertx.java.core.eventbus.EventBus; +import org.vertx.java.core.eventbus.Message; +import org.vertx.java.platform.Verticle; + +public class ExampleVerticle extends Verticle +{ + @Override + public void start() + { + EventBus eventBus = vertx.eventBus(); + + final CountDownLatch latch0 = new CountDownLatch(1); + + // Register a handler on the outgoing connector's address + eventBus.registerHandler(VertxConnectorExample.OUTGOING, + new Handler<Message<?>>() { + @Override + public void handle(Message<?> startMsg) + { + Object body = startMsg.body(); + System.out.println("Verticle receives a message: " + body); + VertxConnectorExample.result.set(VertxConnectorExample.MSG.equals(body)); + latch0.countDown(); + //Tell the example to finish. + VertxConnectorExample.latch.countDown(); + } + }); + + try + { + latch0.await(5000, TimeUnit.MILLISECONDS); + } + catch (InterruptedException e) + { + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/vertx-connector/src/main/java/org/hornetq/core/example/VertxConnectorExample.java ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/src/main/java/org/hornetq/core/example/VertxConnectorExample.java b/examples/core/vertx-connector/src/main/java/org/hornetq/core/example/VertxConnectorExample.java new file mode 100644 index 0000000..12a1e8b --- /dev/null +++ b/examples/core/vertx-connector/src/main/java/org/hornetq/core/example/VertxConnectorExample.java @@ -0,0 +1,114 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.hornetq.core.example; + +import java.net.URL; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.vertx.java.core.AsyncResult; +import org.vertx.java.core.Handler; +import org.vertx.java.core.eventbus.EventBus; +import org.vertx.java.platform.PlatformLocator; +import org.vertx.java.platform.PlatformManager; +import org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory; + +/** + * A simple example of using Vert.x connector service. + * + * @author <a href="[email protected]">Howard Gao</a> + */ +public class VertxConnectorExample +{ + public static final String INCOMING = "incoming.vertx.address"; + public static final String OUTGOING = "outgoing.vertx.address"; + public static final String MSG = "Welcome to Vertx world!"; + + public final static CountDownLatch latch = new CountDownLatch(1); + public final static AtomicBoolean result = new AtomicBoolean(false); + + private static final String HOST = "127.0.0.1"; + private static final int PORT = 0; + + public static void main(final String[] args) throws Exception + { + System.setProperty("vertx.clusterManagerFactory", + HazelcastClusterManagerFactory.class.getName()); + PlatformManager platformManager = null; + + try + { + // Step 1 Create a Vert.x PlatformManager + platformManager = PlatformLocator.factory.createPlatformManager(PORT, HOST); + + final CountDownLatch latch0 = new CountDownLatch(1); + + // Step 2 Deploy a Verticle to receive message + String verticle = "org.hornetq.core.example.ExampleVerticle"; + platformManager.deployVerticle(verticle, null, new URL[0], 1, null, + new Handler<AsyncResult<String>>(){ + + @Override + public void handle(AsyncResult<String> result) + { + if (!result.succeeded()) + { + throw new RuntimeException("failed to deploy verticle", result.cause()); + } + latch0.countDown(); + } + + }); + + latch0.await(); + + // Step 3 Send a message to the incoming connector's address + EventBus bus = platformManager.vertx().eventBus(); + bus.send(INCOMING, MSG); + + // Step 4 Waiting for the Verticle to process the message + latch.await(10000, TimeUnit.MILLISECONDS); + } + finally + { + if(platformManager != null) + { + platformManager.undeployAll(null); + platformManager.stop(); + } + reportResultAndExit(); + } + } + + private static void reportResultAndExit() + { + if (!result.get()) + { + System.err.println(); + System.err.println("#####################"); + System.err.println("### FAILURE! ###"); + System.err.println("#####################"); + System.exit(1); + } + else + { + System.out.println(); + System.out.println("#####################"); + System.out.println("### SUCCESS! ###"); + System.out.println("#####################"); + System.exit(0); + } + } + +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/vertx-connector/src/main/resources/server0/hornetq-beans.xml ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/src/main/resources/server0/hornetq-beans.xml b/examples/core/vertx-connector/src/main/resources/server0/hornetq-beans.xml new file mode 100644 index 0000000..171d373 --- /dev/null +++ b/examples/core/vertx-connector/src/main/resources/server0/hornetq-beans.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<deployment xmlns="urn:jboss:bean-deployer:2.0"> + + <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/> + + <!-- JNDI server. Disable this if you don't want JNDI --> + <bean name="JNDIServer" class="org.jnp.server.Main"> + <property name="namingInfo"> + <inject bean="Naming"/> + </property> + <property name="port">1099</property> + <property name="bindAddress">localhost</property> + <property name="rmiPort">1098</property> + <property name="rmiBindAddress">localhost</property> + </bean> + + <!-- MBean server --> + <bean name="MBeanServer" class="javax.management.MBeanServer"> + <constructor factoryClass="java.lang.management.ManagementFactory" + factoryMethod="getPlatformMBeanServer"/> + </bean> + + <!-- The core configuration --> + <bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration"/> + + <!-- The security manager --> + <bean name="HornetQSecurityManager" class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl"> + <start ignored="true"/> + <stop ignored="true"/> + </bean> + + <!-- The core server --> + <bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl"> + <constructor> + <parameter> + <inject bean="Configuration"/> + </parameter> + <parameter> + <inject bean="MBeanServer"/> + </parameter> + <parameter> + <inject bean="HornetQSecurityManager"/> + </parameter> + </constructor> + <start ignored="true"/> + <stop ignored="true"/> + </bean> + + <!-- The JMS server --> + <bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl"> + <constructor> + <parameter> + <inject bean="HornetQServer"/> + </parameter> + </constructor> + </bean> + +</deployment> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/vertx-connector/src/main/resources/server0/hornetq-configuration.xml ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/src/main/resources/server0/hornetq-configuration.xml b/examples/core/vertx-connector/src/main/resources/server0/hornetq-configuration.xml new file mode 100644 index 0000000..32df466 --- /dev/null +++ b/examples/core/vertx-connector/src/main/resources/server0/hornetq-configuration.xml @@ -0,0 +1,61 @@ +<configuration xmlns="urn:hornetq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd"> + + + <bindings-directory>target/server0/data/messaging/bindings</bindings-directory> + + <journal-directory>target/server0/data/messaging/journal</journal-directory> + + <large-messages-directory>target/server0/data/messaging/largemessages</large-messages-directory> + + <paging-directory>target/server0/data/messaging/paging</paging-directory> + <!-- Connectors --> + + <connectors> + <connector name="netty-connector"> + <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class> + </connector> + </connectors> + + <!-- Acceptors --> + <acceptors> + <acceptor name="netty-acceptor"> + <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class> + </acceptor> + </acceptors> + + <!-- Other config --> + + <security-settings> + <!--security for example queue--> + <security-setting match="queue.vertxQueue"> + <permission type="consume" roles="guest"/> + <permission type="send" roles="guest"/> + </security-setting> + </security-settings> + + <queues> + <queue name="queue.vertxQueue"> + <address>queue.vertxQueue</address> + </queue> + </queues> + + <connector-services> + <connector-service name="my-incoming-vertx"> + <factory-class>org.hornetq.integration.vertx.VertxIncomingConnectorServiceFactory</factory-class> + <param key="queue" value="queue.vertxQueue"/> + <param key="host" value="localhost"/> + <param key="port" value="0"/> + <param key="vertx-address" value="incoming.vertx.address"/> + </connector-service> + <connector-service name="my-outgoing-vertx"> + <factory-class>org.hornetq.integration.vertx.VertxOutgoingConnectorServiceFactory</factory-class> + <param key="queue" value="queue.vertxQueue"/> + <param key="host" value="localhost"/> + <param key="port" value="0"/> + <param key="vertx-address" value="outgoing.vertx.address"/> + </connector-service> + </connector-services> + +</configuration> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/vertx-connector/src/main/resources/server0/hornetq-jms.xml ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/src/main/resources/server0/hornetq-jms.xml b/examples/core/vertx-connector/src/main/resources/server0/hornetq-jms.xml new file mode 100644 index 0000000..678e7f5 --- /dev/null +++ b/examples/core/vertx-connector/src/main/resources/server0/hornetq-jms.xml @@ -0,0 +1,19 @@ +<configuration xmlns="urn:hornetq" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd"> + <!--the connection factory used by the example--> + <connection-factory name="ConnectionFactory"> + <connectors> + <connector-ref connector-name="netty-connector"/> + </connectors> + <entries> + <entry name="ConnectionFactory"/> + </entries> + </connection-factory> + + <!--the queue used by the example--> + <queue name="exampleQueue"> + <entry name="/queue/exampleQueue"/> + </queue> + +</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/core/vertx-connector/src/main/resources/server0/hornetq-users.xml ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/src/main/resources/server0/hornetq-users.xml b/examples/core/vertx-connector/src/main/resources/server0/hornetq-users.xml new file mode 100644 index 0000000..934306c --- /dev/null +++ b/examples/core/vertx-connector/src/main/resources/server0/hornetq-users.xml @@ -0,0 +1,7 @@ +<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd"> + <!-- the default user. this is used where username is null--> + <defaultuser name="guest" password="guest"> + <role name="guest"/> + </defaultuser> +</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/README.md ---------------------------------------------------------------------- diff --git a/examples/javaee/README.md b/examples/javaee/README.md new file mode 100644 index 0000000..faa5a5a --- /dev/null +++ b/examples/javaee/README.md @@ -0,0 +1,12 @@ +Running the Java EE examples +======================== + +To run a javaee example first make sure you have WildFly installed, the examples were tested against against [8.0.0.Final](http://wildfly.org/downloads/). + +Then set the JBOSS_HOME property to your installation, something like: + +export JBOSS_HOME=/home/user/wildfly-8.0.0.Final + +Then simply cd into the directory of the example you want to run and 'mvn test'. + +The examples use [Arquillian](http://www.jboss.org/arquillian.html) to start the JBoss server and to run the example itself. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/ejb-jms-transaction/pom.xml ---------------------------------------------------------------------- diff --git a/examples/javaee/ejb-jms-transaction/pom.xml b/examples/javaee/ejb-jms-transaction/pom.xml new file mode 100644 index 0000000..4d09102 --- /dev/null +++ b/examples/javaee/ejb-jms-transaction/pom.xml @@ -0,0 +1,14 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.hornetq.example.javaee</groupId> + <artifactId>javaee-examples</artifactId> + <version>2.5.0-SNAPSHOT</version> + </parent> + + <artifactId>hornetq-javaee-ejb-jms-example</artifactId> + <packaging>jar</packaging> + <name>HornetQ Java EE MDB EJB Transaction Example</name> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/ejb-jms-transaction/readme.html ---------------------------------------------------------------------- diff --git a/examples/javaee/ejb-jms-transaction/readme.html b/examples/javaee/ejb-jms-transaction/readme.html new file mode 100644 index 0000000..85bbed9 --- /dev/null +++ b/examples/javaee/ejb-jms-transaction/readme.html @@ -0,0 +1,203 @@ +<html> + <head> + <title>HornetQ EJB/JMS Transaction Example</title> + <link rel="stylesheet" type="text/css" href="../../common/common.css" /> + <link rel="stylesheet" type="text/css" href="../../common/prettify.css" /> + <script type="text/javascript" src="../../common/prettify.js"></script> + </head> + <body onload="prettyPrint()"> + <h1>EJB/JMS Transaction Example</h1> + + <p>The example application will invoke an EJB which is deployed within WildFly which will:</p> + <ol> + <li>start an XA transaction</li> + <li>send a JMS message</li> + <li>update an in-memory database</li> + <li>commit the transaction</li> + </ol> + <p>The example application will then receive the message sent by the EJB.</p> + + <h2>WildFly configuration</h2> + + <p>The example leverages the Arquillian framework to run a WildFly instance and deploy the MDB.</p> + + <h2>Example step-by-step</h2> + + <p><i>download WildFly 8.0.0.Final from <a href="http://wildfly.org/downloads/">here</a> and install.</i></p> + <p><i>set the JBOSS_HOME property to point to the WildFly install directory</i></p> + <p><i>type <code>mvn verify</code> from the example directory to run</i></p> + + <p>The example code is composed of two main classes:</p> + <ul> + <li><code>EJBClientExample</code></li> - the example application + <li><code>SendMessageBean</code></li> - a Stateless EJB with a remote interface + </ul> + + <h3>Example Application</h3> + + <p>Let's take a look at EJBClientExample first.</p> + + <ol> + <li>First we need to get an initial context so we can look-up the EJB. This initial context will get it's properties from the jboss-ejb-client.properties.</li> + <pre class="prettyprint"> + Properties env = new Properties(); + env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); + InitialContext initialContext = new InitialContext(); + </pre> + + <li>We look up the EJB</li> + <pre class="prettyprint"> + SendMessageService service = (SendMessageService) initialContext.lookup("ejb:/test//SendMessageBean!org.hornetq.javaee.example.server.SendMessageService"); + </pre> + + <li>We create the DB table which will be updated if it does not already exist</li> + <pre class="prettyprint"> + service.createTable(); + </pre> + + <li>We invoke the EJB's <code>sendAndUpdate</code> method. This method will send a JMS text message (with the text passed in parameter) + and insert a row in the database table with the text and the message's JMS Message ID</li> + <pre class="prettyprint"> + service.sendAndUpdate("This is a text message"); + </pre> + + <p><em>We will now consume the JMS message which was sent by the EJB at step 4.</em></p> + + <li>We need to get a new initial context so we can look-up the JMS connection factory and destination objects from JNDI.</li> + <pre class="prettyprint"> + env = new Properties(); + env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); + env.put(Context.PROVIDER_URL, "http-remoting://localhost:8080"); + initialContext = new InitialContext(env); + </pre> + + <li>We look up the JMS connection factory</li> + <pre class="prettyprint"> + ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("jms/RemoteConnectionFactory"); + </pre> + + <li>We lookup the JMS queue</li> + <pre class="prettyprint"> + Queue queue = (Queue)initialContext.lookup("jms/queues/testQueue"); + </pre> + + <li>We create a connection, a session and a message consumer for the queue</li> + <pre class="prettyprint"> + connection = cf.createConnection("guest", "password"); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageConsumer consumer = session.createConsumer(queue); + </pre> + + <li>We start the JMS connection</li> + <pre class="prettyprint"> + connection.start(); + </pre> + + <li>We receive a message from the queue. It corresponds to the message sent by the EJB</li> + <pre class="prettyprint"> + TextMessage messageReceived = (TextMessage)consumer.receive(5000); + System.out.println("Received message: " + messageReceived.getText() + " (" + messageReceived.getJMSMessageID() + ")"); + </pre> + + <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li> + + <pre class="prettyprint"> + finally + { + if (initialContext != null) + { + initialContext.close(); + } + if (connection != null) + { + connection.close(); + } + } + </pre> + </ol> + + <h3>EJB Example</h3> + + <p>Let's now take a look at the EJB example</p> + + <ol> + <li>First, we create a new initial context</li> + <pre class="prettyprint"> + ic = new InitialContext(); + </pre> + + <li>We look up the JMS <em>XA</em> Connection Factory (which is bound to <code>java:/JmsXA</code>)</li> + <pre class="prettyprint"> + ConnectionFactory cf = (ConnectionFactory)ic.lookup("java:/JmsXA"); + </pre> + + <li>We look up the JMS Queue</li> + <pre class="prettyprint"> + Queue queue = (Queue)ic.lookup("queue/testQueue"); + </pre> + + <li>We create a JMS connection, a session and a message producer for the queue</li> + <pre class="prettyprint"> + jmsConnection = cf.createConnection(); + Session session = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer messageProducer = session.createProducer(queue); + </pre> + + <li>We create a text message with the text passed in parameter of the EJB method</li> + <pre class="prettyprint"> + TextMessage message = session.createTextMessage(text); + </pre> + + <li>We send the message to the queue</li> + <pre class="prettyprint"> + messageProducer.send(message); + System.out.println("Sent message: " + message.getText() + "(" + message.getJMSMessageID() + ")"); + </pre> + + <li>We now lookup the JDBC <em>XA</em> DataSource</li> + <pre class="prettyprint"> + DataSource ds = (DataSource)ic.lookup("java:/XADS"); + </pre> + + <li>We retrieve a JDBC connection</li> + <pre class="prettyprint"> + jdbcConnection = ds.getConnection(); + </pre> + + <li>We create a prepared statement to insert the text and message's ID in the DB table</li> + <pre class="prettyprint"> + PreparedStatement pr = jdbcConnection.prepareStatement("INSERT INTO " + TABLE + + " (id, text) VALUES ('" + message.getJMSMessageID() + "', '" + text + "');"); + </pre> + + <li>We execute the prepared statement</li> + <pre class="prettyprint"> + pr.execute(); + </pre> + + <li>We close the prepared statement</li> + <pre class="prettyprint"> + pr.close(); + </pre> + + <li>And finally, <b>always</b> remember to close all your connections and resources (for both JMS and JDBC) after use, in a <code>finally</code> block.</li> + <pre class="prettyprint"> + finally + { + if (ic != null) + { + ic.close(); + } + if (jmsConnection != null) + { + jmsConnection.close(); + } + if (jdbcConnection != null) + { + jdbcConnection.close(); + } + } + </pre> + </ol> + </body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/ejb-jms-transaction/server/standalone/configuration/application-roles.properties ---------------------------------------------------------------------- diff --git a/examples/javaee/ejb-jms-transaction/server/standalone/configuration/application-roles.properties b/examples/javaee/ejb-jms-transaction/server/standalone/configuration/application-roles.properties new file mode 100644 index 0000000..0ade8fb --- /dev/null +++ b/examples/javaee/ejb-jms-transaction/server/standalone/configuration/application-roles.properties @@ -0,0 +1,22 @@ +# +# Properties declaration of users roles for the realm 'ApplicationRealm'. +# +# This includes the following protocols: remote ejb, remote jndi, web, remote jms +# +# Users can be added to this properties file at any time, updates after the server has started +# will be automatically detected. +# +# The format of this file is as follows: - +# username=role1,role2,role3 +# +# A utility script is provided which can be executed from the bin folder to add the users: - +# - Linux +# bin/add-user.sh +# +# - Windows +# bin\add-user.bat +# +# The following illustrates how an admin user could be defined. +# +#admin=PowerUser,BillingAdmin, +guest=guest http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/ejb-jms-transaction/server/standalone/configuration/application-users.properties ---------------------------------------------------------------------- diff --git a/examples/javaee/ejb-jms-transaction/server/standalone/configuration/application-users.properties b/examples/javaee/ejb-jms-transaction/server/standalone/configuration/application-users.properties new file mode 100644 index 0000000..c52e923 --- /dev/null +++ b/examples/javaee/ejb-jms-transaction/server/standalone/configuration/application-users.properties @@ -0,0 +1,24 @@ +# +# Properties declaration of users for the realm 'ApplicationRealm' which is the default realm +# for application services on a new AS 7.1 installation. +# +# This includes the following protocols: remote ejb, remote jndi, web, remote jms +# +# Users can be added to this properties file at any time, updates after the server has started +# will be automatically detected. +# +# The format of this realm is as follows: - +# username=HEX( MD5( username ':' realm ':' password)) +# +# A utility script is provided which can be executed from the bin folder to add the users: - +# - Linux +# bin/add-user.sh +# +# - Windows +# bin\add-user.bat +# +# The following illustrates how an admin user could be defined, this +# is for illustration only and does not correspond to a usable password. +# +#admin=2a0923285184943425d1f53ddd58ec7a +guest=3437456520927d113b17d471d630e0d6 http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/ejb-jms-transaction/server/standalone/configuration/logging.properties ---------------------------------------------------------------------- diff --git a/examples/javaee/ejb-jms-transaction/server/standalone/configuration/logging.properties b/examples/javaee/ejb-jms-transaction/server/standalone/configuration/logging.properties new file mode 100644 index 0000000..8a011f0 --- /dev/null +++ b/examples/javaee/ejb-jms-transaction/server/standalone/configuration/logging.properties @@ -0,0 +1,52 @@ +# +# JBoss, Home of Professional Open Source. +# Copyright 2010, Red Hat, Inc., and individual contributors +# as indicated by the @author tags. See the copyright.txt file in the +# distribution for a full listing of individual contributors. +# +# This is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of +# the License, or (at your option) any later version. +# +# This software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this software; if not, write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +# 02110-1301 USA, or see the FSF site: http://www.fsf.org. +# + +# Additional logger names to configure (root logger is always configured) +loggers=org.jboss.as.config + +# Dump system environment at boot by default +logger.org.jboss.as.config.level=DEBUG + +# Root logger level +logger.level=${jboss.boot.server.log.level:INFO} +# Root logger handlers +logger.handlers=FILE,CONSOLE + +# Console handler configuration +handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler +handler.CONSOLE.properties=autoFlush +handler.CONSOLE.level=${jboss.boot.server.log.console.level:INFO} +handler.CONSOLE.autoFlush=true +handler.CONSOLE.formatter=PATTERN + +# File handler configuration +handler.FILE=org.jboss.logmanager.handlers.FileHandler +handler.FILE.level=DEBUG +handler.FILE.properties=autoFlush,fileName +handler.FILE.autoFlush=true +handler.FILE.fileName=${org.jboss.boot.log.file:boot.log} +handler.FILE.formatter=PATTERN + +# Formatter pattern configuration +formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter +formatter.PATTERN.properties=pattern +formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n http://git-wip-us.apache.org/repos/asf/activemq-6/blob/8ecd255f/examples/javaee/ejb-jms-transaction/server/standalone/configuration/mgmt-users.properties ---------------------------------------------------------------------- diff --git a/examples/javaee/ejb-jms-transaction/server/standalone/configuration/mgmt-users.properties b/examples/javaee/ejb-jms-transaction/server/standalone/configuration/mgmt-users.properties new file mode 100644 index 0000000..349b004 --- /dev/null +++ b/examples/javaee/ejb-jms-transaction/server/standalone/configuration/mgmt-users.properties @@ -0,0 +1,24 @@ +# +# Properties declaration of users for the realm 'ManagementRealm' which is the default realm +# for new AS 7.1 installations. Further authentication mechanism can be configured +# as part of the <management /> in standalone.xml. +# +# Users can be added to this properties file at any time, updates after the server has started +# will be automatically detected. +# +# By default the properties realm expects the entries to be in the format: - +# username=HEX( MD5( username ':' realm ':' password)) +# +# A utility script is provided which can be executed from the bin folder to add the users: - +# - Linux +# bin/add-user.sh +# +# - Windows +# bin\add-user.bat + +# The following illustrates how an admin user could be defined, this +# is for illustration only and does not correspond to a usable password. +# +#admin=2a0923285184943425d1f53ddd58ec7a +admin=9d71b431e53d99563aa0dfca628c970b +andy=dfb16391f1be1c454b5bce9822bd9df3
