Normally, when you publish an API it will be available in one store. Given the visibility settings it will either be publicly visible, visible to a domain or specific to a role. But what if you want to publish to one or two external API stores as well? Can you do that? Yes you can, quite easily actually. But there are some caveats that you need to be aware of.
How does the mechanism work?
Basically, you point to an external store that is running somewhere on the internet (or your local network). This direction is done using the external-api-stores.xml that is part of the embedded governance repository.
But first things first, let’s set up an external store.
Since it is simple to do this locally, we just unzip a new API Manager with a port offset of 100. That is a random offset that on my machine is open.
Start the API Manager using the bat file or the shell script depending on your OS.
Caveat implementor
What we have here is not a distributed deployment of an API Manager or a standalone connected store.
For such a setup, you need to share databases, make changes to the api-manager.xml configuration and so on. In this case the systems are completely separate and the only connection is a configuration (username/password) to the external store. We will show this a bit later in this blog.
The API is actually deployed on the external API Manager (there is a synapse configuration in the repositorydeploymentserversynapse-configsdefaultapi directory). This is almost a carbon copy of the API in the publisher, the only difference is that the external store has a double version number (it is actually defined twice) in the context. To what extent this is a bug or actually part of the mechanism is unclear. It also seems that the image for the API is not copied to the external store environment (the governance repository).
Visitors to the external store will see minimal information about the API. To subscribe the user needs to visit the publisher store. The API will be invoked within that deployment of course.
You can share an API with application developers who are sub
Setting up external stores
You navigate to the Resources section of the Main tab and open the registry. Navigate to /_system/governance/apimgt/externalstores/external-api-stores.xml
resource.
Click Edit as Text and make the following changes:
<ExternalAPIStores>
<!--Configuration to set the store URL of the current running APIM deployment.
APIs published to external stores will be redirected to this URL-->
<StoreURL>http://localhost:9763/store</StoreURL>
<ExternalAPIStore id="External" type="wso2"
className="org.wso2.carbon.apimgt.impl.publishers.WSO2APIPublisher">
<DisplayName>EXTStore</DisplayName>
<Endpoint>http://localhost:9863/store</Endpoint>
<Username>admin</Username>
<Password>admin</Password>
</ExternalAPIStore>
</ExternalAPIStores>
The parameters are reasonably self-explanatory, basically defining the Store Displayname, Endpoint and the credentials used for accessing the store to publish the API.
In a multi-tenant environment, each tenant can publish to different external Stores by changing the above file in their tenant space. As with a non-tenant environment the user needs to visit the original store to subscribe and the invocation will happen over the gateway of the original API Manager.
Publishing to an external store
When the external store is defined an extra TAB is visible in the Publisher once the API is Published.
Selecting the External API Stores tab allows you to check the external store(s) you want to publish to.
When you click Save the API will be available in the external store.
If you have any questions about this blogpost contact us via the comments section of this blog. View also our WSO2 Tutorials, webinars or white papers for more technical information. Need support? We do deliver WSO2 Product Support, WSO2 Development Support, WSO2 Operational Support and WSO2 Training Programs.