Wowza Community

set application instance property on HttpProvider

I tried to receive parameters from HttpProvider and pass to the next incoming stream, so I put the following code on onHTTPRequest method

IApplicationInstance appInstance = vhost.getApplication("live").getAppInstance("_definst_");
		
WMSProperties props = appInstance.getProperties();
synchronized (props)
{
	Map<String, Map<String, String>> storeInfo = (Map<String, Map<String, String>>) props.getProperty("streamStoreInfo");
	if (storeInfo == null)
		storeInfo = new HashMap<String, Map<String, String>>();
			
	Map<String, String> items = new HashMap<String, String>();
	items.put("path", path);
	storeInfo.put(streamName, items );
			
	props.put("streamStoreInfo", storeInfo);
}

The HttpProvider would be called before stream upload to WMS.

And also I created a customer module to get the property on onAppStart method

WMSProperties props = appInstance.getProperties();
synchronized (props)
{
	Map<String, Map<String, String>> storeInfo = (Map<String, Map<String, String>>) props.getProperty("streamStoreInfo");
	getLogger().info("[onAppStart]: "+storeInfo);
}

But the desired property does NOT exist when onAppStart is calling, How should I pass the parameter to application instance or stream that will come later?

Yehudi

Hi,

When you call IApplicationInstance appInstance = vhost.getApplication(“live”).getAppInstance(“definst”); on an appInstance that is not loaded, it will trigger the appInstance to load up so will call onAppStart. When onAppStart is called, your http provider has not created the map or put it into the props so the appInstance cannot see it.

The easiest way around it would be to store the map at the VHost level in vhost properties or a custom class and then when onAppStart is called, get the map from there.

This method would also work across appInstance restarts. When an appInstance stops & starts, it is a new class instance so any settings in the old one are lost.

Roger.

Thank your useful reply. It lets me know what’s correct timing that onAppStart is called. :slight_smile:

And for my case, I should NOT try to get the appInstance’s property on onAppStart, I should do it on some methods like onStreamCreate, then I can put the parameter as appInstance’s property.

Thanks again.

Yehudi