xmlBlaster 2.2.0 API

javaclients
Class HelloWorldSubscribe

java.lang.Object
  extended by javaclients.HelloWorldSubscribe
All Implemented Interfaces:
I_Callback

public class HelloWorldSubscribe
extends java.lang.Object
implements I_Callback

This client connects to xmlBlaster and subscribes to messages.

This is a nice client to experiment and play with xmlBlaster as there are many command line options to specify the type and amount of messages published.

Try using 'java javaclients.HelloWorldPublish' in another window to publish some messages. Further you can type 'd' in the window running xmlBlaster to get a server dump.

Invoke (after starting the xmlBlaster server):
 java javaclients.HelloWorldSubscribe -xpath //key -initialUpdate true -unSubscribe true

 java javaclients.HelloWorldSubscribe -interactive false -oid Hello -initialUpdate true -unSubscribe true

 java javaclients.HelloWorldSubscribe -session.name joeSubscriber/5 -passwd secret -initialUpdate true -dump[HelloWorldSubscribe] true

 java javaclients.HelloWorldSubscribe -xpath //key -filter.type GnuRegexFilter -filter.query "^__sys__jdbc.*"

 java javaclients.HelloWorldSubscribe -xpath //key -filter.type XPathFilter -filter.query "//tomato"

 java javaclients.HelloWorldSubscribe -xpath //key -filter.type ContentLenFilter -filter.query "10"
 

If unSubscribe=false the message is not unsubscribed at the end, if disconnect=false we don't logout at the end.

See Also:
javaclients.HelloWorldPublish, javaclients.HelloWorldGet, xmlBlaster interface

Nested Class Summary
 class HelloWorldSubscribe.HelloThread
           
 
Field Summary
private  boolean autoSubscribe
           
private  java.util.Map clientPropertyMap
           
private  I_XmlBlasterAccess con
           
private  boolean connectPersistent
           
private  java.util.Map connectQosClientPropertyMap
           
private  boolean connectRefreshSession
           
private  java.lang.String domain
           
private  boolean dumpToConsole
           
private  boolean dumpToFile
           
private  java.lang.String fileDateFormat
           
private  java.lang.String fileExtension
           
private  java.lang.String fileHeader
           
private  java.lang.String fileLock
           
private  java.lang.String filePrefix
           
private  java.lang.String filterQuery
           
private  java.lang.String filterType
           
private  java.lang.String filterVersion
           
private  boolean firstConnect
           
private  java.text.DateFormat formatter
           
private  Global glob
           
private  boolean historyNewestFirst
           
private  int historyNumUpdates
           
private  boolean initialUpdate
           
private  boolean interactive
           
private  boolean interactiveUpdate
           
private  boolean local
           
private static java.util.logging.Logger log
           
private  int maxContentLength
           
private  java.lang.String ME
           
private  boolean multiSubscribe
           
private  boolean notifyOnErase
           
private  java.lang.String oid
           
private  boolean persistentSubscribe
           
private  boolean runAsDaemon
           
private  boolean shutdownCbServer
           
private  SubscribeReturnQos srq
           
private  java.lang.String subscribeServerId
           
private  boolean unSubscribe
           
private  int updateCounter
           
private  java.lang.String updateExceptionErrorCode
           
private  java.lang.String updateExceptionMessage
           
private  java.lang.String updateExceptionRuntime
           
private  boolean updateOneway
           
private  long updateSleep
           
private  boolean wantContent
           
private  java.lang.String xpath
           
 
Constructor Summary
HelloWorldSubscribe()
           
HelloWorldSubscribe(Global global_)
           
 
Method Summary
private  java.lang.String formatDate(long timestamp)
          Convert the long milli second time to a readable format as given with fileDateFormat.
static void main(java.lang.String[] args)
          Try
 void process(Global glob_)
           
 void processAsync(Global glob_)
           
private  void readEnv()
           
private  void subscribe()
          Does the xmlBlaster subscribe.
 java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos)
          Here the messages from xmlBlaster arrive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private final java.lang.String ME
See Also:
Constant Field Values

glob

private Global glob

log

private static java.util.logging.Logger log

con

private I_XmlBlasterAccess con

srq

private SubscribeReturnQos srq

subscribeServerId

private java.lang.String subscribeServerId

updateCounter

private int updateCounter

connectPersistent

private boolean connectPersistent

firstConnect

private boolean firstConnect

interactive

private boolean interactive

autoSubscribe

private boolean autoSubscribe

interactiveUpdate

private boolean interactiveUpdate

updateSleep

private long updateSleep

updateExceptionErrorCode

private java.lang.String updateExceptionErrorCode

updateExceptionMessage

private java.lang.String updateExceptionMessage

updateExceptionRuntime

private java.lang.String updateExceptionRuntime

shutdownCbServer

private boolean shutdownCbServer

oid

private java.lang.String oid

domain

private java.lang.String domain

xpath

private java.lang.String xpath

multiSubscribe

private boolean multiSubscribe

persistentSubscribe

private boolean persistentSubscribe

notifyOnErase

private boolean notifyOnErase

local

private boolean local

initialUpdate

private boolean initialUpdate

updateOneway

private boolean updateOneway

wantContent

private boolean wantContent

dumpToFile

private boolean dumpToFile

fileExtension

private java.lang.String fileExtension

filePrefix

private java.lang.String filePrefix

fileDateFormat

private java.lang.String fileDateFormat

formatter

private volatile java.text.DateFormat formatter

fileLock

private java.lang.String fileLock

fileHeader

private java.lang.String fileHeader

historyNumUpdates

private int historyNumUpdates

historyNewestFirst

private boolean historyNewestFirst

filterType

private java.lang.String filterType

filterVersion

private java.lang.String filterVersion

filterQuery

private java.lang.String filterQuery

unSubscribe

private boolean unSubscribe

maxContentLength

private int maxContentLength

connectRefreshSession

private boolean connectRefreshSession

runAsDaemon

private boolean runAsDaemon

dumpToConsole

private boolean dumpToConsole

clientPropertyMap

private java.util.Map clientPropertyMap

connectQosClientPropertyMap

private java.util.Map connectQosClientPropertyMap
Constructor Detail

HelloWorldSubscribe

public HelloWorldSubscribe()

HelloWorldSubscribe

public HelloWorldSubscribe(Global global_)
Method Detail

readEnv

private void readEnv()

processAsync

public void processAsync(Global glob_)

process

public void process(Global glob_)

subscribe

private void subscribe()
Does the xmlBlaster subscribe.


update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               byte[] content,
                               UpdateQos updateQos)
                        throws XmlBlasterException
Here the messages from xmlBlaster arrive.

Specified by:
update in interface I_Callback
Parameters:
cbSessionId - The session ID specified by the client which registered the callback. You can specify a cbSessionId during connection (with ConnectQos) and this is bounced back here so you can authenticate the message.
updateKey - The arrived key containing the topic name
content - The arrived message content. This is your payload.
Throws:
XmlBlasterException
See Also:
I_XmlBlasterAccess

formatDate

private java.lang.String formatDate(long timestamp)
Convert the long milli second time to a readable format as given with fileDateFormat. "yyyy-MM-dd'T'HHmmss" or with milli seconds "yyyy-MM-dd'T'HHmmss.S"

Returns:
Defaults to "2005-06-19T152029.344" (ISO 8601)

main

public static void main(java.lang.String[] args)
Try
   java javaclients.HelloWorldSubscribe -help
 
for usage help


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.