Search in sources :

Example 1 with AddMessage

use of jp.ossc.nimbus.service.publish.tcp.AddMessage in project nimbus by nimbus-org.

the class ClientConnectionImpl method addSubject.

public void addSubject(String subject, String[] keys) throws MessageSendException {
    if (socket == null) {
        throw new MessageSendException("Not connected.");
    }
    if (subject == null) {
        return;
    }
    try {
        send(new AddMessage(subject, keys), isAcknowledge);
    } catch (SocketTimeoutException e) {
        throw new MessageSendException(e);
    } catch (SocketException e) {
        throw new MessageSendException(e);
    } catch (IOException e) {
        throw new MessageSendException(e);
    } catch (ClassNotFoundException e) {
        throw new MessageSendException(e);
    }
    if (subjects == null) {
        subjects = Collections.synchronizedMap(new HashMap());
    }
    Set keySet = (Set) subjects.get(subject);
    if (keySet == null) {
        keySet = Collections.synchronizedSet(new HashSet());
        subjects.put(subject, keySet);
    }
    if (keys == null) {
        keySet.add(null);
    } else {
        for (int i = 0; i < keys.length; i++) {
            keySet.add(keys[i]);
        }
    }
}
Also used : SocketException(java.net.SocketException) MessageSendException(jp.ossc.nimbus.service.publish.MessageSendException) SocketTimeoutException(java.net.SocketTimeoutException) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) IOException(java.io.IOException) AddMessage(jp.ossc.nimbus.service.publish.tcp.AddMessage) HashSet(java.util.HashSet)

Aggregations

IOException (java.io.IOException)1 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 MessageSendException (jp.ossc.nimbus.service.publish.MessageSendException)1 AddMessage (jp.ossc.nimbus.service.publish.tcp.AddMessage)1