Class OnapMsgRouterSubscriber.Builder
- java.lang.Object
-
- io.continual.onap.services.mrCommon.CommonClientBuilder
-
- io.continual.onap.services.subscriber.OnapMsgRouterSubscriber.Builder
-
- Enclosing class:
- OnapMsgRouterSubscriber
public static class OnapMsgRouterSubscriber.Builder extends CommonClientBuilder
A builder for the subscriber.
-
-
Field Summary
Fields Modifier and Type Field Description static intNO_RECV_LIMIT
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OnapMsgRouterSubscriber.BuilderasUser(String user, String pwd)Set HTTP basic auth credentials.OnapMsgRouterSubscriberbuild()Build the subscriber given this specification.OnapMsgRouterSubscriber.BuilderdefaultHttp()If no protocol is provided on a host string, default to http://OnapMsgRouterSubscriber.BuilderdefaultHttps()If no protocol is provided on a host string, default to https://OnapMsgRouterSubscriber.BuilderdefaultHttps(boolean https)If no protocol is provided on a host string, default to https:// if true, http:// if false.OnapMsgRouterSubscriber.BuilderforgetHosts()Clear any hosts the builder already knows about.OnapMsgRouterSubscriber.BuilderinGroup(String group)Specify the subscriber group that this subscriber belongs to.OnapMsgRouterSubscriber.BuildernoRecvLimit()Do not specify a maximum number of events to return on a fetch, allowing the server to determine the number to send.OnapMsgRouterSubscriber.BuilderonTopic(String topic)Specify the topic to publish to.OnapMsgRouterSubscriber.BuilderparseWith(JsonResponseParser p)Provide a response parser.OnapMsgRouterSubscriber.BuilderrecvAtMostEvents(int eventCount)Specify the maximum number of events to return on a fetch.OnapMsgRouterSubscriber.BuildersocketWaitAtMost(long ms)Specify the amount of time to wait on a socket connection, read, or write.OnapMsgRouterSubscriber.BuilderusingProxy(String proxy)Specify a proxy to use for the HTTP connection to Message Router.OnapMsgRouterSubscriber.BuilderusingProxy(String host, int port)Specify a proxy to use for the HTTP connection to Message Router.OnapMsgRouterSubscriber.BuilderwaitAtServerAtMost(long ms)Specify the amount of time to wait at the server for messages.OnapMsgRouterSubscriber.BuilderwithApiKey(String apiKey, String apiSecret)Set an API key and secret.OnapMsgRouterSubscriber.BuilderwithClock(Clock clock)Specify a clock to use within this implementation.OnapMsgRouterSubscriber.BuilderwithHost(String host)Add a host to the set the publisher can use.OnapMsgRouterSubscriber.BuilderwithHosts(String[] hosts)Add each host to the host list.OnapMsgRouterSubscriber.BuilderwithHosts(Collection<String> hosts)Add each host to the host list.OnapMsgRouterSubscriber.BuilderwithSubscriberId(String id)Specify the subscriber id for this subscriber.-
Methods inherited from class io.continual.onap.services.mrCommon.CommonClientBuilder
getClock, getCredentials, getDefaultHttps, getHosts, getLog, getProxy, getProxyHost, getProxyPort, getSocketWaitMs, getTopic, isProxied, logTo, waitingAtMost
-
-
-
-
Field Detail
-
NO_RECV_LIMIT
public static final int NO_RECV_LIMIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
withHost
public OnapMsgRouterSubscriber.Builder withHost(String host)
Add a host to the set the publisher can use. If you do not provide a protocol, "http://" is assumed. You may specify "https://" or "http://". If you do not provide a port (e.g. "host:3904"), then 3904 is assumed for http, and 3905 for https. Thus "localhost" is treated as "http://localhost:3904".- Overrides:
withHostin classCommonClientBuilder- Parameters:
host- the host to add to the host set- Returns:
- this builder
-
withHosts
public OnapMsgRouterSubscriber.Builder withHosts(Collection<String> hosts)
Add each host to the host list. See withHost ( String host ) for details.- Overrides:
withHostsin classCommonClientBuilder- Parameters:
hosts- a collection of hosts to add to the host set- Returns:
- this builder
-
withHosts
public OnapMsgRouterSubscriber.Builder withHosts(String[] hosts)
Add each host to the host list. See withHost ( String host ) for details.- Overrides:
withHostsin classCommonClientBuilder- Parameters:
hosts- a collection of hosts to add to the host set- Returns:
- this builder
-
forgetHosts
public OnapMsgRouterSubscriber.Builder forgetHosts()
Clear any hosts the builder already knows about.- Overrides:
forgetHostsin classCommonClientBuilder- Returns:
- this builder
-
onTopic
public OnapMsgRouterSubscriber.Builder onTopic(String topic)
Specify the topic to publish to.- Overrides:
onTopicin classCommonClientBuilder- Parameters:
topic- the topic on which to post messages- Returns:
- this builder
-
inGroup
public OnapMsgRouterSubscriber.Builder inGroup(String group)
Specify the subscriber group that this subscriber belongs to.- Parameters:
group- the subscriber group name- Returns:
- this builder
-
withSubscriberId
public OnapMsgRouterSubscriber.Builder withSubscriberId(String id)
Specify the subscriber id for this subscriber. This must be unique across members of the group.- Parameters:
id- the unique subscriber ID in the group- Returns:
- this builder
-
waitAtServerAtMost
public OnapMsgRouterSubscriber.Builder waitAtServerAtMost(long ms)
Specify the amount of time to wait at the server for messages. This is essentially a long-poll mechanism supported by the ONAP Message Router system.- Parameters:
ms- the number of milliseconds to wait at the server for messages.- Returns:
- this builder
-
recvAtMostEvents
public OnapMsgRouterSubscriber.Builder recvAtMostEvents(int eventCount)
Specify the maximum number of events to return on a fetch.- Parameters:
eventCount- the number of events to return at most- Returns:
- this builder
-
noRecvLimit
public OnapMsgRouterSubscriber.Builder noRecvLimit()
Do not specify a maximum number of events to return on a fetch, allowing the server to determine the number to send.- Returns:
- this builder
-
socketWaitAtMost
public OnapMsgRouterSubscriber.Builder socketWaitAtMost(long ms)
Specify the amount of time to wait on a socket connection, read, or write.- Overrides:
socketWaitAtMostin classCommonClientBuilder- Parameters:
ms- the number of milliseconds to wait for a socket operation (connect/read/write)- Returns:
- this builder
-
asUser
public OnapMsgRouterSubscriber.Builder asUser(String user, String pwd)
Set HTTP basic auth credentials. If user is null, the auth info is removed from the builder.- Overrides:
asUserin classCommonClientBuilder- Parameters:
user- the username for basic auth credentialspwd- the password for basic auth credentials- Returns:
- this builder
-
withApiKey
public OnapMsgRouterSubscriber.Builder withApiKey(String apiKey, String apiSecret)
Set an API key and secret. If the API key is null, the auth info is removed from the builder.- Overrides:
withApiKeyin classCommonClientBuilder- Parameters:
apiKey- the API key for the userapiSecret- the API key's secret- Returns:
- this builder
-
defaultHttp
public OnapMsgRouterSubscriber.Builder defaultHttp()
If no protocol is provided on a host string, default to http://- Overrides:
defaultHttpin classCommonClientBuilder- Returns:
- this builder
-
defaultHttps
public OnapMsgRouterSubscriber.Builder defaultHttps()
If no protocol is provided on a host string, default to https://- Overrides:
defaultHttpsin classCommonClientBuilder- Returns:
- this builder
-
defaultHttps
public OnapMsgRouterSubscriber.Builder defaultHttps(boolean https)
If no protocol is provided on a host string, default to https:// if true, http:// if false.- Overrides:
defaultHttpsin classCommonClientBuilder- Parameters:
https- if true, use https. if false, use http- Returns:
- this builder
-
withClock
public OnapMsgRouterSubscriber.Builder withClock(Clock clock)
Specify a clock to use within this implementation.- Overrides:
withClockin classCommonClientBuilder- Parameters:
clock- the clock to use for timing- Returns:
- this builder
-
usingProxy
public OnapMsgRouterSubscriber.Builder usingProxy(String proxy)
Specify a proxy to use for the HTTP connection to Message Router.- Overrides:
usingProxyin classCommonClientBuilder- Parameters:
proxy- a proxy string, which can optionally end in :port, e.g. proxy.example.com:8888- Returns:
- this builder
-
usingProxy
public OnapMsgRouterSubscriber.Builder usingProxy(String host, int port)
Specify a proxy to use for the HTTP connection to Message Router.- Overrides:
usingProxyin classCommonClientBuilder- Parameters:
host- a proxy host nameport- a port number- Returns:
- this builder
-
parseWith
public OnapMsgRouterSubscriber.Builder parseWith(JsonResponseParser p)
Provide a response parser.- Parameters:
p- the reponse parser- Returns:
- this builder
-
build
public OnapMsgRouterSubscriber build()
Build the subscriber given this specification.- Returns:
- a new subscriber
-
-