Getting platform parameters when its deprecated

What product/components do you use and which version/fix level are you on?

Version of cumulocity 1015

Is your question related to the free trial, or to a production (customer) instance?

production

What are you trying to achieve? Please describe it in detail.

I want to subscribe to all operations within a microservice using the following code:

	Subscriber subscriber = SubscriberBuilder.<String, OperationRepresentation>anSubscriber()
						.withEndpoint("cep/realtime").withParameters(**parameters**)
						.withSubscriptionNameResolver(new Identity()).withDataType(OperationRepresentation.class)
						.build();
				Subscription<String> subscription = subscriber.subscribe("/operations/*",
						new OperationDispatcherSubscriptionListener());

Do you get any error messages? Please provide a full error message screenshot and log file.

The log says that platform params have now been depracated. How can i get these in order to substitute it in the variable. The parameters var is mandatory.

Description:

Field platform in com.c8y.ms.templates.realtime.controller.NotificationController required a bean of type ‘com.cumulocity.sdk.client.PlatformImpl’ that could not be found.

Action:

Bean of this type is no longer available.
Instead inject platform APIs directly or inject com.cumulocity.sdk.client.Platform and get the same platform APIs instances with getters.
Use relative URL’s starting with ‘/’ with RestConnector bean to have them resolved automatically against the host defined in PlatformParameters#getHost().

Have you installed all the latest fixes for the products and systems you are using?

@Autowired
       private RestConnector restConnector;

InventoryRealtimeDeleteAwareNotificationsSubscriber subscriber = new InventoryRealtimeDeleteAwareNotificationsSubscriber(restConnector.getPlatformParameters());

subscriber.subscribe("*",
                           new SubscriptionListener<String, ManagedObjectDeleteAwareNotification>() {
                    @Override
                    public void onNotification(Subscription<String> arg0, ManagedObjectDeleteAwareNotification notification) {
[…]

2 Likes

            PlatformParameters platform = new PlatformParameters(
                                                        http://cumulocity:8111, 
                                                        microserviceCredentials.toCumulocityCredentials(), 
                                                        new ClientConfiguration());

InventoryRealtimeDeleteAwareNotificationsSubscriber subscriber = new InventoryRealtimeDeleteAwareNotificationsSubscriber(platform);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.