Skip to content

Commit

Permalink
Update documentation and samples
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejlach committed Jan 14, 2015
1 parent 5f1076f commit 5273e1b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions doc/Usage-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public class Console {

## Subscribing for asynchronous messages
This example shows how to create a simple subscription for asynchronous data using the `QMessageListener` interface:
> :white_check_mark: Warning:
> this sample code overwrites: .z.ts and sub functions on q process
```java
import java.io.IOException;
Expand All @@ -171,8 +173,8 @@ import com.exxeleron.qjava.QMessagesListener;
public class Subscriber {

public static void main( final String[] args ) throws IOException {
final QCallbackConnection q = new QCallbackConnection(args.length >= 1 ? args[0] : "localhost", args.length >= 2 ? Integer.parseInt(args[1]) : 5001,
"", "");
final int port = args.length >= 2 ? Integer.parseInt(args[1]) : 5001;
final QCallbackConnection q = new QCallbackConnection(args.length >= 1 ? args[0] : "localhost", port, "", "");

final QMessagesListener listener = new QMessagesListener() {

Expand All @@ -191,6 +193,7 @@ public class Subscriber {
q.addMessagesListener(listener);
try {
q.open(); // open connection
System.out.println("WARNING: this application overwrites: .z.ts and sub functions on q process running on port: " + port);
System.out.println("Press <ENTER> to close application");

q.sync("sub:{[x] .sub.h: .z.w }"); // subscription definition
Expand Down
11 changes: 6 additions & 5 deletions src/sample/java/Subscriber.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2011-2014 Exxeleron GmbH
*
*
* Licensed 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.
Expand All @@ -23,8 +23,8 @@
public class Subscriber {

public static void main( final String[] args ) throws IOException {
final QCallbackConnection q = new QCallbackConnection(args.length >= 1 ? args[0] : "localhost", args.length >= 2 ? Integer.parseInt(args[1]) : 5001,
"", "");
final int port = args.length >= 2 ? Integer.parseInt(args[1]) : 5001;
final QCallbackConnection q = new QCallbackConnection(args.length >= 1 ? args[0] : "localhost", port, "", "");

final QMessagesListener listener = new QMessagesListener() {

Expand All @@ -43,6 +43,7 @@ public void errorReceived( final QErrorMessage message ) {
q.addMessagesListener(listener);
try {
q.open(); // open connection
System.out.println("WARNING: this application overwrites: .z.ts and sub functions on q process running on port: " + port);
System.out.println("Press <ENTER> to close application");

q.sync("sub:{[x] .sub.h: .z.w }"); // subscription definition
Expand Down
2 changes: 1 addition & 1 deletion src/sample/java/TickSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class TickSubscriber {

public static void main( final String[] args ) throws IOException {
final QCallbackConnection q = new QCallbackConnection("localhost", 9010, "", "");
final QCallbackConnection q = new QCallbackConnection("localhost", 17010, "", "");
final QMessagesListener listener = new QMessagesListener() {

public void messageReceived( final QMessage message ) {
Expand Down

0 comments on commit 5273e1b

Please sign in to comment.